summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-30 08:35:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-30 08:35:23 +0000
commit1852b4a8660ee8e71997f81cee4903c6eb23f306 (patch)
tree651e33765db8a4d18ab102ea1ef38fc6f5deafc2 /ext/bigdecimal
parentd00c9d7e0609f6d9b6141e1dde6fa9321de70b85 (diff)
ext: check if null byte is contained
[ruby-dev:50267] [Bug #13953] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index d6bc8bdaa7..e9e6af7784 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -289,8 +289,9 @@ again:
#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 */
@@ -430,8 +431,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)) {
@@ -2037,8 +2038,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++;