summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-01 12:12:44 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-01 12:12:44 (GMT)
commite8d2806cfc4137b65a2e2da41fe7f515007d3d57 (patch)
tree8db9ce5bcd5c3cebfcaf14e1faada746bac0ac3b /transcode.c
parente7fac351c2d46696a5de85710e765327e8346cce (diff)
transcode.c: fix segv in String.encode!
* transcode.c (str_transcode0): fix segv in String.encode!. now rb_str_scrub() can return nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/transcode.c b/transcode.c
index 92fd806..38694268 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2699,7 +2699,9 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
if (!NIL_P(ecopts)) {
rep = rb_hash_aref(ecopts, sym_replace);
}
- *self = rb_str_scrub(str, rep);
+ dest = rb_str_scrub(str, rep);
+ if (NIL_P(dest)) dest = str;
+ *self = dest;
return dencidx;
}
return NIL_P(arg2) ? -1 : dencidx;