Fix potential NULL dereference in new code for surrogate escapes, discovered by

Coverity Scan.
This commit is contained in:
Philip.Hazel 2017-05-23 16:47:29 +00:00
parent 231a800557
commit fef4de56a1
1 changed files with 4 additions and 4 deletions

View File

@ -1667,8 +1667,8 @@ else
} }
else if (ptr < ptrend && *ptr++ == CHAR_RIGHT_CURLY_BRACKET) else if (ptr < ptrend && *ptr++ == CHAR_RIGHT_CURLY_BRACKET)
{ {
if (utf && c >= 0xd800 && c <= 0xdfff && if (utf && c >= 0xd800 && c <= 0xdfff && (cb == NULL ||
(cb->cx->extra_options & PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES) == 0) (cb->cx->extra_options & PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES) == 0))
{ {
ptr--; ptr--;
*errorcodeptr = ERR73; *errorcodeptr = ERR73;
@ -1737,8 +1737,8 @@ else
} }
else if (ptr < ptrend && *ptr++ == CHAR_RIGHT_CURLY_BRACKET) else if (ptr < ptrend && *ptr++ == CHAR_RIGHT_CURLY_BRACKET)
{ {
if (utf && c >= 0xd800 && c <= 0xdfff && if (utf && c >= 0xd800 && c <= 0xdfff && (cb == NULL ||
(cb->cx->extra_options & PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES) == 0) (cb->cx->extra_options & PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES) == 0))
{ {
ptr--; ptr--;
*errorcodeptr = ERR73; *errorcodeptr = ERR73;