Paranoid check in regcomp() for bad error code from pcre2_compile().

This commit is contained in:
Philip.Hazel 2015-11-13 17:26:42 +00:00
parent 5dce5b3727
commit c8ed1e8feb
2 changed files with 8 additions and 1 deletions

View File

@ -299,6 +299,8 @@ regcomp() error instead of waiting for regexec() to pick it up.
88. In pcre2_substitute(), ensure that CRLF is not split when it is a valid
newline sequence.
89. Paranoid check in regcomp() for bad error code from pcre2_compile().
Version 10.20 30-June-2015
--------------------------

View File

@ -217,8 +217,13 @@ preg->re_erroffset = erroffset;
if (preg->re_pcre2_code == NULL)
{
unsigned int i;
if (errorcode < 0) return REG_BADPAT; /* UTF error */
/* A negative value is a UTF error; otherwise all error codes are greater
than COMPILE_ERROR_BASE, but check, just in case. */
if (errorcode < COMPILE_ERROR_BASE) return REG_BADPAT;
errorcode -= COMPILE_ERROR_BASE;
if (errorcode < (int)(sizeof(eint1)/sizeof(const int)))
return eint1[errorcode];
for (i = 0; i < sizeof(eint2)/(2*sizeof(const int)); i += 2)