p->locals may be NULL when error occurs before the point.

This is reported by oss-fuzz:
Issue 19886: mruby:mruby_fuzzer: Potential-null-reference in setup_numparams
This commit is contained in:
Yukihiro "Matz" Matsumoto
2020-01-08 01:18:53 +09:00
parent afad939173
commit dbba0ca517
+2 -1
View File
@@ -845,7 +845,8 @@ setup_numparams(parser_state *p, node *a)
if (a && (a->car || (a->cdr && a->cdr->car) || (a->cdr->cdr && a->cdr->cdr->car) || (a->cdr->cdr->cdr->cdr && a->cdr->cdr->cdr->cdr->car))) {
yyerror(p, "ordinary parameter is defined");
}
else {
else if (p->locals) {
/* p->locals should not be NULL unless error happens before the point */
node* args = 0;
for (i = nvars; i > 0; i--) {
char buf[3];