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
This commit is contained in:
nobu 2013-11-01 12:12:44 +00:00
parent e7fac351c2
commit e8d2806cfc
1 changed files with 3 additions and 1 deletions

View File

@ -2699,7 +2699,9 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
if (!NIL_P(ecopts)) { if (!NIL_P(ecopts)) {
rep = rb_hash_aref(ecopts, sym_replace); 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 dencidx;
} }
return NIL_P(arg2) ? -1 : dencidx; return NIL_P(arg2) ? -1 : dencidx;