According to <http://www.pcre.org/current/doc/html/pcre2api.html#SEC15>:
> STRING LENGTHS AND OFFSETS
>
> The PCRE2 API uses string lengths and offsets into strings of code units
> in several places. These values are always of type PCRE2_SIZE, which is
> an unsigned integer type, currently always defined as size_t. The
> largest value that can be stored in such a type (that is ~(PCRE2_SIZE)0)
> is reserved as a special indicator for zero-terminated strings and unset
> offsets. Therefore, the longest string that can be handled is one less
> than this maximum.
Therefore check the validity of ovector[1] with
ovector[1] != ~(PCRE2_SIZE)0
rather than the always-true
ovector[1] >= 0
This was caught by gcc's
> miniexpect.c:359:45: warning: comparison of unsigned expression in ‘>=
> 0’ is always true [-Wtype-limits]
which is part of "-Wextra".
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
if (match_data)
ovector = pcre2_get_ovector_pointer (match_data);
- if (ovector != NULL && ovector[1] >= 0)
+ if (ovector != NULL && ovector[1] != ~(PCRE2_SIZE)0)
h->next_match = ovector[1];
else
h->next_match = -1;