[#1026] Is this a bug? — Dave Thomas <Dave@...>

18 messages 2000/01/03

[#1084] Infinite loop — Dave Thomas <Dave@...>

17 messages 2000/01/11

[#1104] The value of while... — Dave Thomas <Dave@...>

24 messages 2000/01/11

[ruby-talk:01140] Re: Bug in String

From: matz@... (Yukihiro Matsumoto)
Date: 2000-01-14 03:24:23 UTC
List: ruby-talk #1140
Hi,

In message "[ruby-talk:01139] Bug in String"
    on 00/01/13, Dave Thomas <Dave@thomases.com> writes:

|     ruby> a = 'abcdef'
|     ruby> a[1] = a
|     "aaaaaaacdef"

|I think it's because str_replace uses memcpy on an overlapping string 
|(two copies of RSTRING(a)->ptr in this case). memcpy is specified not
|to work on overlapping strings.

Changing memcpy to memmove in rb_str_replace worked well.
Thank you for finding a bug.  

							matz.

In This Thread