Fix possible negative index possibility in pcre2test.

This commit is contained in:
Philip.Hazel 2016-06-14 16:14:52 +00:00
parent 4db9b51ce0
commit 16acce6555
2 changed files with 7 additions and 1 deletions

View File

@ -134,6 +134,8 @@ RunTest (see 4 above).
34. Fix comment describing the returns from find_fixedlength().
35. Fix potential negative index in pcre2test.
Version 10.21 12-January-2016
-----------------------------

View File

@ -3016,9 +3016,13 @@ for (;;)
}
dlen = strlen((char *)here);
if (here[dlen - 1] == '\n') return start; /* End of line reached */
here += dlen;
/* Check for end of line reached. Take care not to read data from before
start (dlen will be zero for a file starting with a binary zero). */
if (here > start && here[-1] == '\n') return start;
/* If we have not read a newline when reading a file, we have either filled
the buffer or reached the end of the file. We can detect the former by
checking that the string fills the buffer, and the latter by feof(). If