diff --git a/ChangeLog b/ChangeLog index cae32dbf3f..771e09db8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Sep 1 22:02:08 2006 Yukihiro Matsumoto + + * string.c (rb_str_resize): should copy embedded string to + malloc'ed buffer. a patch from in + [ruby-dev:29369]. fixed: [ruby-dev:29368] + + * string.c (rb_str_ord): use %ld specifier since STRING_LEN() is a + long. [ruby-dev:29369] + Fri Sep 1 21:41:12 2006 Yukihiro Matsumoto * ext/socket/socket.c (socks_init): typo fixed. a patch from Sven diff --git a/array.c b/array.c index 3cf5b7ceb3..d50df152d5 100644 --- a/array.c +++ b/array.c @@ -2826,7 +2826,7 @@ rb_ary_shuffle_bang(VALUE ary) * call-seq: * array.shuffle -> an_array * - * Returns a new array that with elements of this array shuffled. + * Returns a new array with elements of this array shuffled. * * a = [ 1, 2, 3 ] #=> [1, 2, 3] * a.shuffle #=> [2, 3, 1] diff --git a/string.c b/string.c index d28b2da2e1..6482e32c51 100644 --- a/string.c +++ b/string.c @@ -682,12 +682,15 @@ rb_str_resize(VALUE str, long len) rb_str_modify(str); if (len != RSTRING_LEN(str)) { if (STR_EMBED_P(str)) { + char *ptr; if (len <= RSTRING_EMBED_LEN_MAX) { STR_SET_EMBED_LEN(str, len); RSTRING_PTR(str)[len] = '\0'; return str; } - RSTRING(str)->as.heap.ptr = ALLOC_N(char,len+1); + ptr = ALLOC_N(char,len+1); + MEMCPY(ptr, RSTRING(str)->ary, char, RSTRING_LEN(str)); + RSTRING(str)->as.heap.ptr = ptr; STR_SET_NOEMBED(str); } else if (RSTRING_LEN(str) < len || RSTRING_LEN(str) - len > 1024) { @@ -4165,7 +4168,7 @@ rb_str_ord(VALUE s) if (RSTRING_LEN(s) != 1) { rb_raise(rb_eTypeError, - "expacted a characer, but string of size %d given", + "expacted a characer, but string of size %ld given", RSTRING_LEN(s)); } c = RSTRING_PTR(s)[0] & 0xff;