Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
5d0c8a70
Commit
5d0c8a70
authored
9 years ago
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2777 from cremno/fix-parser-locals-null-deref
parser: fix possible null dereferences
parents
8d1f9a6e
c1821257
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
src/parse.y
src/parse.y
+14
-9
No files found.
src/parse.y
View file @
5d0c8a70
...
...
@@ -271,12 +271,17 @@ local_add(parser_state *p, mrb_sym sym)
}
}
static node*
locals_node(parser_state *p)
{
return p->locals ? p->locals->car : NULL;
}
/* (:scope (vars..) (prog...)) */
static node*
new_scope(parser_state *p, node *body)
{
node *n = p->locals ? p->locals->car : NULL;
return cons((node*)NODE_SCOPE, cons(n, body));
return cons((node*)NODE_SCOPE, cons(locals_node(p), body));
}
/* (:begin prog...) */
...
...
@@ -603,35 +608,35 @@ new_undef(parser_state *p, mrb_sym sym)
static node*
new_class(parser_state *p, node *c, node *s, node *b)
{
return list4((node*)NODE_CLASS, c, s, cons(
p->locals->car
, b));
return list4((node*)NODE_CLASS, c, s, cons(
locals_node(p)
, b));
}
/* (:sclass obj body) */
static node*
new_sclass(parser_state *p, node *o, node *b)
{
return list3((node*)NODE_SCLASS, o, cons(
p->locals->car
, b));
return list3((node*)NODE_SCLASS, o, cons(
locals_node(p)
, b));
}
/* (:module module body) */
static node*
new_module(parser_state *p, node *m, node *b)
{
return list3((node*)NODE_MODULE, m, cons(
p->locals->car
, b));
return list3((node*)NODE_MODULE, m, cons(
locals_node(p)
, b));
}
/* (:def m lv (arg . body)) */
static node*
new_def(parser_state *p, mrb_sym m, node *a, node *b)
{
return list5((node*)NODE_DEF, nsym(m),
p->locals->car
, a, b);
return list5((node*)NODE_DEF, nsym(m),
locals_node(p)
, a, b);
}
/* (:sdef obj m lv (arg . body)) */
static node*
new_sdef(parser_state *p, node *o, mrb_sym m, node *a, node *b)
{
return list6((node*)NODE_SDEF, o, nsym(m),
p->locals->car
, a, b);
return list6((node*)NODE_SDEF, o, nsym(m),
locals_node(p)
, a, b);
}
/* (:arg . sym) */
...
...
@@ -669,14 +674,14 @@ new_block_arg(parser_state *p, node *a)
static node*
new_block(parser_state *p, node *a, node *b)
{
return list4((node*)NODE_BLOCK,
p->locals->car
, a, b);
return list4((node*)NODE_BLOCK,
locals_node(p)
, a, b);
}
/* (:lambda arg body) */
static node*
new_lambda(parser_state *p, node *a, node *b)
{
return list4((node*)NODE_LAMBDA,
p->locals->car
, a, b);
return list4((node*)NODE_LAMBDA,
locals_node(p)
, a, b);
}
/* (:asgn lhs rhs) */
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment