[svn:parrot] r48804 - trunk/src/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Sun Sep 5 22:17:25 UTC 2010


Author: NotFound
Date: Sun Sep  5 22:17:24 2010
New Revision: 48804
URL: https://trac.parrot.org/parrot/changeset/48804

Log:
build a new string from the buffer instead of cloning a not fully valid string in StringBuilder get_string

Modified:
   trunk/src/pmc/stringbuilder.pmc

Modified: trunk/src/pmc/stringbuilder.pmc
==============================================================================
--- trunk/src/pmc/stringbuilder.pmc	Sun Sep  5 19:11:41 2010	(r48803)
+++ trunk/src/pmc/stringbuilder.pmc	Sun Sep  5 22:17:24 2010	(r48804)
@@ -143,11 +143,15 @@
 */
 
     VTABLE STRING *get_string() {
-        STRING *buffer;
+        STRING *buffer, *result;
         GET_ATTR_buffer(INTERP, SELF, buffer);
-        /* We need to clone buffer because outside of StringBuilder strings */
-        /* are immutable */
-        return Parrot_str_clone(INTERP, buffer);
+        /* We need to build a new string because outside of StringBuilder
+         * strings are immutable. Don't use Parrot_str_clone, the buffer
+         * is not a STRING valid enough for that. */
+        result = Parrot_str_new_init(INTERP,
+            buffer->strstart, buffer->bufused,
+            buffer->encoding, buffer->charset,
+            0);
     }
 
 /*


More information about the parrot-commits mailing list