Skip to content

Commit

Permalink
ext: check if null byte is contained
Browse files Browse the repository at this point in the history
[ruby-dev:50267] [Bug #13953]

git-svn-id: svn+ssh://svn.ruby-lang.org/ruby/trunk@60071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu authored and mrkn committed Dec 13, 2017
1 parent 86b5d13 commit f87b73e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ext/bigdecimal/bigdecimal.c
Expand Up @@ -293,8 +293,9 @@ GetVpValueWithPrec(VALUE v, long prec, int must)

#ifdef ENABLE_NUMERIC_STRING
case T_STRING:
SafeStringValue(v);
return VpCreateRbObject(strlen(RSTRING_PTR(v)) + VpBaseFig() + 1,
StringValueCStr(v);
rb_check_safe_obj(v);
return VpCreateRbObject(RSTRING_LEN(v) + VpBaseFig() + 1,
RSTRING_PTR(v));
#endif /* ENABLE_NUMERIC_STRING */

Expand Down Expand Up @@ -434,8 +435,8 @@ BigDecimal_load(VALUE self, VALUE str)
unsigned char ch;
unsigned long m=0;

SafeStringValue(str);
pch = (unsigned char *)RSTRING_PTR(str);
pch = (unsigned char *)StringValueCStr(str);
rb_check_safe_obj(str);
/* First get max prec */
while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') {
if(!ISDIGIT(ch)) {
Expand Down Expand Up @@ -2042,8 +2043,8 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)

if (rb_scan_args(argc, argv, "01", &f) == 1) {
if (RB_TYPE_P(f, T_STRING)) {
SafeStringValue(f);
psz = RSTRING_PTR(f);
psz = StringValueCStr(f);
rb_check_safe_obj(f);
if (*psz == ' ') {
fPlus = 1;
psz++;
Expand Down

0 comments on commit f87b73e

Please sign in to comment.