From 9761245a7a25e23f24f16ecc8f5902548bb72394 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 30 Nov 2003 00:35:28 +0000 Subject: * string.c (rb_str_update): get rid of SEGV at just allocated String. [ruby-core:01812] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ string.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 941f7a111..c7143225d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 30 09:35:14 2003 Nobuyoshi Nakada + + * string.c (rb_str_update): get rid of SEGV at just allocated String. + [ruby-core:01812] + Fri Nov 28 23:19:34 2003 Yukihiro Matsumoto * gc.c (gc_mark): explicitly check mark recursion levels, instead diff --git a/string.c b/string.c index eebc61cd1..d0ccce767 100644 --- a/string.c +++ b/string.c @@ -1314,7 +1314,9 @@ rb_str_update(str, beg, len, val) memmove(RSTRING(str)->ptr+beg, RSTRING(val)->ptr, RSTRING(val)->len); } RSTRING(str)->len += RSTRING(val)->len - len; - RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; + if (RSTRING(str)->ptr) { + RSTRING(str)->ptr[RSTRING(str)->len] = '\0'; + } OBJ_INFECT(str, val); } -- cgit