summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-01-08 01:18:53 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-01-08 01:18:53 +0900
commitdbba0ca517ad0c32cdd7f0bd68de9c35145e1735 (patch)
tree41fab35ad1d16606219c5a1a6d4e566503095ab1
parentafad9391734998df4f76a6f7108278d2aa2599a0 (diff)
downloadmruby-dbba0ca517ad0c32cdd7f0bd68de9c35145e1735.tar.gz
mruby-dbba0ca517ad0c32cdd7f0bd68de9c35145e1735.zip
`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
-rw-r--r--mrbgems/mruby-compiler/core/parse.y3
1 files changed, 2 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 993cbca8c..0a5eb2a7b 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -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];