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
e5b61d34
Commit
e5b61d34
authored
Apr 06, 2017
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed possible SEGV in `Kernel#block_given?`; ref #3593
parent
5e79bc93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
29 deletions
+23
-29
src/kernel.c
src/kernel.c
+23
-29
No files found.
src/kernel.c
View file @
e5b61d34
...
@@ -136,44 +136,38 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self)
...
@@ -136,44 +136,38 @@ mrb_f_block_given_p_m(mrb_state *mrb, mrb_value self)
{
{
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
mrb_callinfo
*
ci
=
mrb
->
c
->
ci
;
mrb_value
*
bp
;
mrb_value
*
bp
;
mrb_bool
given_p
;
bp
=
ci
->
stackent
+
1
;
bp
=
ci
->
stackent
+
1
;
ci
--
;
ci
--
;
if
(
ci
<=
mrb
->
c
->
cibase
)
{
if
(
ci
<=
mrb
->
c
->
cibase
)
{
given_p
=
FALSE
;
return
mrb_false_value
()
;
}
}
else
{
/* block_given? called within block; check upper scope */
/* block_given? called within block; check upper scope */
if
(
ci
->
proc
->
env
)
{
if
(
ci
->
proc
->
env
)
{
struct
REnv
*
e
=
ci
->
proc
->
env
;
struct
REnv
*
e
=
ci
->
proc
->
env
;
mrb_value
*
sp
;
while
(
e
->
c
)
{
while
(
e
->
c
)
{
e
=
(
struct
REnv
*
)
e
->
c
;
e
=
(
struct
REnv
*
)
e
->
c
;
}
sp
=
e
->
stack
;
if
(
sp
)
{
/* top-level does not have block slot (alway false) */
if
(
sp
==
mrb
->
c
->
stbase
)
return
mrb_false_value
();
if
(
e
->
cioff
<
0
)
{
/* use saved block arg position */
bp
=
&
e
->
stack
[
-
e
->
cioff
];
}
else
{
ci
=
mrb
->
c
->
cibase
+
e
->
cioff
;
bp
=
ci
[
1
].
stackent
+
1
;
}
}
}
}
if
(
ci
->
argc
>
0
)
{
/* top-level does not have block slot (always false) */
bp
+=
ci
->
argc
;
if
(
e
->
stack
==
mrb
->
c
->
stbase
)
return
mrb_false_value
();
if
(
e
->
stack
&&
e
->
cioff
<
0
)
{
/* use saved block arg position */
bp
=
&
e
->
stack
[
-
e
->
cioff
];
ci
=
0
;
/* no callinfo available */
}
else
{
ci
=
mrb
->
c
->
cibase
+
e
->
cioff
;
bp
=
ci
[
1
].
stackent
+
1
;
}
}
given_p
=
!
mrb_nil_p
(
*
bp
);
}
}
if
(
ci
&&
ci
->
argc
>
0
)
{
return
mrb_bool_value
(
given_p
);
bp
+=
ci
->
argc
;
}
if
(
mrb_nil_p
(
*
bp
))
return
mrb_false_value
();
return
mrb_true_value
();
}
}
/* 15.3.1.3.7 */
/* 15.3.1.3.7 */
...
...
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