[svn:parrot] r46396 - trunk/src/dynpmc

fperrad at svn.parrot.org fperrad at svn.parrot.org
Fri May 7 21:37:03 UTC 2010


Author: fperrad
Date: Fri May  7 21:37:03 2010
New Revision: 46396
URL: https://trac.parrot.org/parrot/changeset/46396

Log:
[Gziphandle] fix uncompress

Modified:
   trunk/src/dynpmc/gziphandle.pmc

Modified: trunk/src/dynpmc/gziphandle.pmc
==============================================================================
--- trunk/src/dynpmc/gziphandle.pmc	Fri May  7 19:55:30 2010	(r46395)
+++ trunk/src/dynpmc/gziphandle.pmc	Fri May  7 21:37:03 2010	(r46396)
@@ -307,7 +307,7 @@
                 "failed to allocate");
 
         srcLen = Parrot_str_byte_length(INTERP, str);
-        dstLen = srcLen;
+        dstLen = 2 * srcLen;
     REDO:
         buf = mem_allocate_n_zeroed_typed(dstLen, char);
 
@@ -318,15 +318,16 @@
         }
 
         rc = uncompress((Bytef *)buf, &dstLen, (const Bytef *)src, srcLen);
-        Parrot_str_free_cstring(src);
 
         switch (rc) {
           case Z_OK:
+            Parrot_str_free_cstring(src);
             dst = Parrot_str_new(INTERP, buf, dstLen);
             mem_sys_free(buf);
             break;
 
           case Z_MEM_ERROR:
+            Parrot_str_free_cstring(src);
             mem_sys_free(buf);
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
                 "not enough memory");
@@ -338,13 +339,14 @@
             goto REDO;
 
           case Z_DATA_ERROR:
+            Parrot_str_free_cstring(src);
             mem_sys_free(buf);
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_ILL_INHERIT,
                 "input data corrupted");
             break;
 
           default:
-            /* these are the only three documented return values */
+            /* these are the only four documented return values */
             break;
         }
 


More information about the parrot-commits mailing list