From: Derrick Pallas Date: Sun, 3 Feb 2019 02:38:05 +0000 (-0800) Subject: regerror/toascii: do not attempt to serialize NULL pointer X-Git-Tag: v6.9.2_rc1~74^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93d95ff8d66d7dfaf64c385c265c173193b14dfb;p=onig regerror/toascii: do not attempt to serialize NULL pointer This has been seen in the wild, e.g. [1], and while I have not investigated how a NULL made it in here, this should prevent similar future bugs causing a SEGFAULT. [1] https://github.com/stedolan/jq/issues/1803 --- diff --git a/src/regerror.c b/src/regerror.c index 3fbcdfe..d4671c0 100644 --- a/src/regerror.c +++ b/src/regerror.c @@ -211,7 +211,11 @@ static int to_ascii(OnigEncoding enc, UChar *s, UChar *end, UChar *p; OnigCodePoint code; - if (ONIGENC_MBC_MINLEN(enc) > 1) { + if (!s) { + len = 0; + *is_over = 0; + } + else if (ONIGENC_MBC_MINLEN(enc) > 1) { p = s; len = 0; while (p < end) {