]> granicus.if.org Git - php/commitdiff
fix mem leak
authorAnatol Belski <ab@php.net>
Fri, 2 Sep 2016 09:33:17 +0000 (11:33 +0200)
committerAnatol Belski <ab@php.net>
Fri, 2 Sep 2016 17:46:32 +0000 (19:46 +0200)
ext/standard/image.c

index f39c6709795e9c1dcafef15abbe6bf20666dd66f..c5616d111955380925736620255d8fda4aca2a44 100644 (file)
@@ -209,21 +209,27 @@ static struct gfxinfo *php_handle_swc(php_stream * stream)
 
        b = ecalloc(1, len + 1);
 
-       if (php_stream_seek(stream, 5, SEEK_CUR))
+       if (php_stream_seek(stream, 5, SEEK_CUR)) {
+               efree(b);
                return NULL;
+       }
 
-       if (php_stream_read(stream, (char *) a, sizeof(a)) != sizeof(a))
+       if (php_stream_read(stream, (char *) a, sizeof(a)) != sizeof(a)) {
+               efree(b);
                return NULL;
+       }
 
        if (uncompress(b, &len, a, sizeof(a)) != Z_OK) {
                /* failed to decompress the file, will try reading the rest of the file */
                if (php_stream_seek(stream, 8, SEEK_SET)) {
+                       efree(b);
                        return NULL;
                }
 
                bufz = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0);
 
                if (!bufz) {
+                       efree(b);
                        return NULL;
                }