From cea5e4cbda65f3e37d3c75dc29cbef7126d2a8a4 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 30 Jun 2008 11:36:43 +0000 Subject: merge revision(s) 17530: * string.c (str_buf_cat): check for self concatenation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@17735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ string.c | 9 ++++++++- version.h | 8 ++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5a7146f34..24035d8323 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Jun 30 20:35:32 2008 Nobuyoshi Nakada + + * string.c (str_buf_cat): check for self concatenation. + Sun Jun 29 21:39:54 2008 Tanaka Akira * eval.c (rb_obj_respond_to): use RTEST to test the result of diff --git a/string.c b/string.c index 2d40ccf0a4..d66268abb8 100644 --- a/string.c +++ b/string.c @@ -708,9 +708,13 @@ str_buf_cat(str, ptr, len) const char *ptr; long len; { - long capa, total; + long capa, total, off = -1;; rb_str_modify(str); + if (ptr >= RSTRING(str)->ptr && ptr <= RSTRING(str)->ptr + RSTRING(str)->len) { + off = ptr - RSTRING(str)->ptr; + } + if (len == 0) return 0; if (FL_TEST(str, STR_ASSOC)) { FL_UNSET(str, STR_ASSOC); capa = RSTRING(str)->aux.capa = RSTRING(str)->len; @@ -732,6 +736,9 @@ str_buf_cat(str, ptr, len) } RESIZE_CAPA(str, capa); } + if (off != -1) { + ptr = RSTRING(str)->ptr + off; + } memcpy(RSTRING(str)->ptr + RSTRING(str)->len, ptr, len); RSTRING(str)->len = total; RSTRING(str)->ptr[total] = '\0'; /* sentinel */ diff --git a/version.h b/version.h index ce4f414d4d..11263a3043 100644 --- a/version.h +++ b/version.h @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2008-06-29" +#define RUBY_RELEASE_DATE "2008-06-30" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20080629 -#define RUBY_PATCHLEVEL 38 +#define RUBY_RELEASE_CODE 20080630 +#define RUBY_PATCHLEVEL 39 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 29 +#define RUBY_RELEASE_DAY 30 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; -- cgit v1.2.3