Give error for zero timing argument to pcre2test.

This commit is contained in:
Philip.Hazel 2019-07-03 17:15:37 +00:00
parent 4866bd3652
commit a5c601091e
2 changed files with 13 additions and 0 deletions

View File

@ -83,6 +83,8 @@ and last consulted characters.
if the end of the subject was encountered in a lookahead (conditional or if the end of the subject was encountered in a lookahead (conditional or
otherwise), an atomic group, or a recursion. otherwise), an atomic group, or a recursion.
16. Give error if pcre2test -t, -T, -tm or -TM is given an argument of zero.
Version 10.33 16-April-2019 Version 10.33 16-April-2019
--------------------------- ---------------------------

View File

@ -3269,6 +3269,11 @@ return 0;
/* This function is no longer used. Keep it around for a while, just in case it
needs to be re-instated. */
#ifdef NEVERNEVERNEVER
/************************************************* /*************************************************
* Move back by so many characters * * Move back by so many characters *
*************************************************/ *************************************************/
@ -3313,6 +3318,7 @@ else /* 16-bit mode */
return pp - (PCRE2_SPTR16)subject; return pp - (PCRE2_SPTR16)subject;
} }
} }
#endif /* NEVERNEVERNEVER */
@ -8652,6 +8658,11 @@ while (argc > 1 && argv[op][0] == '-' && argv[op][1] != 0)
showtotaltimes = arg[1] == 'T'; showtotaltimes = arg[1] == 'T';
if (argc > 2 && (uli = strtoul(argv[op+1], &endptr, 10), *endptr == 0)) if (argc > 2 && (uli = strtoul(argv[op+1], &endptr, 10), *endptr == 0))
{ {
if (uli == 0)
{
fprintf(stderr, "** Argument for %s must not be zero\n", arg);
exit(1);
}
if (U32OVERFLOW(uli)) if (U32OVERFLOW(uli))
{ {
fprintf(stderr, "** Argument for %s is too big\n", arg); fprintf(stderr, "** Argument for %s is too big\n", arg);