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

Coverity Scan.
This commit is contained in:
ph10 2017-05-23 16:47:29 +00:00
parent b4a77c8f2b
commit 84b70b36d7

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;