The string_grow function (currently used only by string_replace) does not
allocate a new buffer if there are no bytes to be copied from old buffer to
new buffer. Patch below fixes this.

--
Peter Gibbs
EmKel Systems

Index: string.c
===================================================================
RCS file: /home/perlcvs/parrot/string.c,v
retrieving revision 1.68
diff -u -r1.68 string.c
--- string.c  12 Apr 2002 01:40:28 -0000  1.68
+++ string.c  12 Apr 2002 08:20:54 -0000
@@ -76,11 +76,11 @@
     INTVAL copysize = s->bufused;
     if(addlen < 0)
         copysize += addlen;
-    if(copysize <= 0)
-        return s;
     /* Don't check buflen, if we are here, we already checked. */
     newbuf = Parrot_allocate(interpreter, s->buflen + addlen);
-    mem_sys_memcopy(newbuf, s->bufstart, (UINTVAL)copysize);
+    if (copysize > 0) {
+        mem_sys_memcopy(newbuf, s->bufstart, (UINTVAL)copysize);
+    }
     s->bufstart = newbuf;
     s->buflen += addlen;
     return s;


Reply via email to