Hi Sean,

On Mon, Oct 14, 2002 at 04:13:02AM +0900, Sean Chittenden wrote:
> > $ ruby -e 'p [].to_s.strip.to_i'
> > -e:1: [BUG] Segmentation fault
> > ruby 1.7.3 (2002-09-27) [i386-freebsd4]
> > Abort (core dumped)
> > 
> > See attached.  -sc
> 
> FWIW, I'm not sure that I have the right fix because to_f has the same
> problem.  Was there a change that uncovered this bug, or, has
> something else closer to the core changed that'd result in passing a
> NULL string to the various methods?  Anyway, if this were the correct
> fix bug in bignum, then the following would always SEGV ruby.  The bug
> appears to be in chaining methods together.  Hit four methods and
> you're SOL.  -sc

	your patch was OK, but incomplete. This could help with the
	rest.

Index: bignum.c
===================================================================
RCS file: /src/ruby/bignum.c,v
retrieving revision 1.78
diff -u -p -r1.78 bignum.c
--- bignum.c	2002/10/07 07:43:41	1.78
+++ bignum.c	2002/10/13 20:13:13
@@ -502,6 +505,10 @@ rb_str_to_inum(str, base, badcheck)
     StringValue(str);
     s = RSTRING(str)->ptr;
     len = RSTRING(str)->len;
+    
+    if (!s) {
+	return INT2FIX(0);
+    }
     if (s[len]) {		/* no sentinel somehow */
 	char *p = ALLOCA_N(char, len+1);

Index: object.c
===================================================================
RCS file: /src/ruby/object.c,v
retrieving revision 1.89
diff -u -p -r1.89 object.c
--- object.c	2002/10/04 17:54:29	1.89
+++ object.c	2002/10/13 20:13:14
@@ -1093,6 +1093,9 @@ rb_str_to_dbl(str, badcheck)
     StringValue(str);
     s = RSTRING(str)->ptr;
     len = RSTRING(str)->len;
+    if (!s) {
+	    return 0.0;
+    }
     if (s[len]) {		/* no sentinel somehow */
 	char *p = ALLOCA_N(char, len+1);

	To allow NULL wasn't maybe a good idea :)

	BR

		Michal
 
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ing. Michal Rokos                    Czech Technical University, Prague
e-mail: m.rokos / sh.cvut.cz    icq: 36118339     jabber: majkl / jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-