From a5031810492e168e0a834521112f42777d431506 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@5058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index eebc61cd10..d0ccce7671 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 v1.2.3