mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* object.c (rb_str_to_dbl): Fix again. use rb_str_tmp_new()
instead ALLOC_N. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c11a4d8f3f
commit
cab9751e97
2 changed files with 12 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Jan 24 22:26:33 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* 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@fsij.org>
|
Mon Jan 24 21:50:48 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* vm_insnhelper.h: parenthesize macro arguments.
|
* vm_insnhelper.h: parenthesize macro arguments.
|
||||||
|
|
11
object.c
11
object.c
|
@ -2246,7 +2246,7 @@ rb_str_to_dbl(VALUE str, int badcheck)
|
||||||
char *s;
|
char *s;
|
||||||
long len;
|
long len;
|
||||||
double ret;
|
double ret;
|
||||||
char *alloced = NULL;
|
VALUE tmp = Qnil;
|
||||||
|
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
s = RSTRING_PTR(str);
|
s = RSTRING_PTR(str);
|
||||||
|
@ -2256,15 +2256,18 @@ rb_str_to_dbl(VALUE str, int badcheck)
|
||||||
rb_raise(rb_eArgError, "string for Float contains null byte");
|
rb_raise(rb_eArgError, "string for Float contains null byte");
|
||||||
}
|
}
|
||||||
if (s[len]) { /* no sentinel somehow */
|
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);
|
MEMCPY(p, s, char, len);
|
||||||
p[len] = '\0';
|
p[len] = '\0';
|
||||||
s = p;
|
s = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = rb_cstr_to_dbl(s, badcheck);
|
ret = rb_cstr_to_dbl(s, badcheck);
|
||||||
if (alloced)
|
if (tmp != Qnil)
|
||||||
xfree(alloced);
|
rb_str_resize(tmp, 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue