On Sunday 29 April 2007 11:18:20 Joshua Isom wrote:

> I've done realclean a few times actually.  If I run with r18322, it
> runs just fine, but r18323, which dealt with zero length mallocs for
> strings, caused it to start crashing.  Here's a backtrace.  This is one
> of those tests where with -G it succeeds, so you'll have to make sure
> that gc is enabled.  I'm not having any trouble on my darwin/ppc
> machine, but my only two running platforms are darwin/ppc and
> freebsd/amd64.

Here's a patch that fixes a related bug in Tcl on certain platforms.  How does 
it fare for you?

-- c

=== src/string.c
==================================================================
--- src/string.c	(revision 3342)
+++ src/string.c	(local)
@@ -399,24 +399,22 @@
 */
 
 STRING *
-string_append(Interp *interp,
-    STRING *a, STRING *b)
+string_append(Interp *interp, STRING *a, STRING *b)
 {
-    UINTVAL a_capacity, b_len;
-    UINTVAL total_length;
-    CHARSET *cs;
+    UINTVAL   a_capacity, b_len;
+    UINTVAL   total_length;
+    CHARSET  *cs;
     ENCODING *enc;
 
     /* XXX should this be a CHARSET method? */
 
     /* If B isn't real, we just bail */
     b_len = string_length(interp, b);
-    if (!b_len) {
+    if (!b_len)
         return a;
-    }
 
-    /* Is A real? */
-    if (a == NULL)
+    /* Is A real and non-empty? */
+    if (a == NULL || PObj_bufstart(a) == NULL)
         return string_copy(interp, b);
 
     saneify_string(a);
@@ -424,9 +422,8 @@
 
     /* If the destination's constant, or external then just fall back to
        string_concat */
-    if (PObj_is_cowed_TESTALL(a)) {
+    if (PObj_is_cowed_TESTALL(a))
         return string_concat(interp, a, b, 0);
-    }
 
     cs = string_rep_compatible(interp, a, b, &enc);
     if (cs != NULL) {
@@ -444,10 +441,9 @@
         if (b->encoding == Parrot_utf16_encoding_ptr)
             a->encoding = Parrot_utf16_encoding_ptr;
     }
-    /*
-     * calc usable and total bytes
-     */
-    a_capacity = string_capacity(interp, a);
+
+    /* calc usable and total bytes */
+    a_capacity   = string_capacity(interp, a);
     total_length = a->bufused + b->bufused;
 
     /* make sure A's big enough for both  */
@@ -463,8 +459,9 @@
             b->strstart, b->bufused);
 
     a->bufused += b->bufused;
-    a->strlen += b_len;
-    a->hashval = 0;
+    a->strlen  += b_len;
+    a->hashval  = 0;
+
     return a;
 }
 

Reply via email to