Skip to content

Commit

Permalink
Diagnose negative repeat value in pcre2test subject line
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipHazel committed Aug 16, 2022
1 parent 3a1ad41 commit 94e1c00
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ pointers had out of place PCRE2_CALL_CONVENTION in src/pcre2.h.*. These
produced errors when building for Windows with #define PCRE2_CALL_CONVENTION
__stdcall.

20. A negative repeat value in a pcre2test subject line was not being
diagnosed, leading to infinite looping.


Version 10.40 15-April-2022
---------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/pcre2test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6844,9 +6844,9 @@ while ((c = *p++) != 0)
}

i = (int32_t)li;
if (i-- == 0)
if (i-- <= 0)
{
fprintf(outfile, "** Zero repeat not allowed\n");
fprintf(outfile, "** Zero or negative repeat not allowed\n");
return PR_OK;
}

Expand Down
3 changes: 3 additions & 0 deletions testdata/testinput2
Original file line number Diff line number Diff line change
Expand Up @@ -5932,4 +5932,7 @@ a)"xI
/[Aa]{2,3}/BI
aabcd

--
\[X]{-10}

# End of testinput2
4 changes: 4 additions & 0 deletions testdata/testoutput2
Original file line number Diff line number Diff line change
Expand Up @@ -17746,6 +17746,10 @@ Subject length lower bound = 2
aabcd
0: aa

--
\[X]{-10}
** Zero or negative repeat not allowed

# End of testinput2
Error -70: PCRE2_ERROR_BADDATA (unknown error number)
Error -62: bad serialized data
Expand Down

0 comments on commit 94e1c00

Please sign in to comment.