ruby-changes:18622
From: kosaki <ko1@a...>
Date: Tue, 25 Jan 2011 03:27:34 +0900 (JST)
Subject: [ruby-changes:18622] Ruby:r30645 (trunk): * object.c (rb_str_to_dbl): Fix again. use rb_str_tmp_new()
kosaki 2011-01-25 03:23:05 +0900 (Tue, 25 Jan 2011) New Revision: 30645 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30645 Log: * object.c (rb_str_to_dbl): Fix again. use rb_str_tmp_new() instead ALLOC_N. Modified files: trunk/ChangeLog trunk/object.c Index: ChangeLog =================================================================== --- ChangeLog (revision 30644) +++ ChangeLog (revision 30645) @@ -1,3 +1,8 @@ +Mon Jan 24 22:26:33 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * object.c (rb_str_to_dbl): Fix again. use rb_str_tmp_new() + instead ALLOC_N. + Mon Jan 24 21:50:48 2011 Tanaka Akira <akr@f...> * vm_insnhelper.h: parenthesize macro arguments. Index: object.c =================================================================== --- object.c (revision 30644) +++ object.c (revision 30645) @@ -2246,7 +2246,7 @@ char *s; long len; double ret; - char *alloced = NULL; + VALUE tmp = Qnil; StringValue(str); s = RSTRING_PTR(str); @@ -2256,15 +2256,18 @@ rb_raise(rb_eArgError, "string for Float contains null byte"); } if (s[len]) { /* no sentinel somehow */ - char *p = alloced = ALLOC_N(char, len+1); + char *p; + + tmp = rb_str_tmp_new(len); + p = RSTRING_PTR(tmp); MEMCPY(p, s, char, len); p[len] = '\0'; s = p; } } ret = rb_cstr_to_dbl(s, badcheck); - if (alloced) - xfree(alloced); + if (tmp != Qnil) + rb_str_resize(tmp, 0); return ret; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/