[#3006] CVS repository — "Eugene Scripnik" <hoaz@...>

Hello.

21 messages 2004/06/16
[#3008] Re: CVS repository — ts <decoux@...> 2004/06/16

>>>>> "E" == Eugene Scripnik <hoaz@gala.net> writes:

[#3009] Re: CVS repository — Michal Rokos <michal@...> 2004/06/16

Hi!

[#3057] Ruby 1.8.2 to be released. — matz@... (Yukihiro Matsumoto)

Hi,

20 messages 2004/06/23

Re: 1.8.2: Segfault / Addition

From: Mikael Brockman <phubuh@...>
Date: 2004-06-26 18:11:17 UTC
List: ruby-core #3100
Elven <elven@elven.de> writes:

> 
> E> Just run the code:
> E>   if false begin
> E>   end
>   
> Sorry, i was being overly stupid; i pasted the wrong code snippet.
> It should be:
> 
> return false if begin
> end

The culprit is that `begin end' creates a begin NODE whose nd_body is
0.  All conditionals use expr_value, which replaces the top of the parse
stack with the node's nd_body.  So you'll see a segfault for any
conditional involving an empty begin-end.

I'm not sure if this is the proper way to fix things -- this is actually
the first time I've looked at the Ruby source -- but this prevents
nullary begins being created by setting such bodies to nil instead.

--- parse.y     25 May 2004 02:54:21 -0000      1.326
+++ parse.y     26 Jun 2004 18:10:25 -0000
@@ -1448,7 +1448,10 @@
                  bodystmt
                  kEND
                    {
-                       $$ = NEW_BEGIN($3);
+                        if ($3 == NULL)
+                          $$ = NEW_NIL();
+                        else
+                         $$ = NEW_BEGIN($3);
                        nd_set_line($$, $<num>1);
                    }
                | tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen

  mikael


In This Thread

Prev Next