com php-src: fix double free and move temps into local scope: ext/gd/libgd/gd_webp.c
| From: | Anatol Belski | Date: | Mon, 07 Mar 2016 15:38:47 +0000 |
| Subject: | com php-src: fix double free and move temps into local scope: ext/gd/libgd/gd_webp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91280@lists.php.net to get a copy of this message | ||
Commit: f7e81fd9f15de2afdd23dc75c0341fc94664f2b3
Author: Anatol Belski <ab@php.net> Mon, 7 Mar 2016 16:38:47 +0100
Parents: 0fccddba75c68e7dd70f26ee595995bffba6dfe1
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f7e81fd9f15de2afdd23dc75c0341fc94664f2b3
Log:
fix double free and move temps into local scope
Changed paths:
M ext/gd/libgd/gd_webp.c
Diff:
diff --git a/ext/gd/libgd/gd_webp.c b/ext/gd/libgd/gd_webp.c
index e85e9d9..da0cc9d 100644
--- a/ext/gd/libgd/gd_webp.c
+++ b/ext/gd/libgd/gd_webp.c
@@ -39,13 +39,14 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
int width, height;
uint8_t *filedata = NULL;
uint8_t *argb = NULL;
- unsigned char *read, *temp;
size_t size = 0, n;
gdImagePtr im;
int x, y;
uint8_t *p;
do {
+ unsigned char *read, *temp;
+
temp = gdRealloc(filedata, size+GD_WEBP_ALLOC_STEP);
if (temp) {
filedata = temp;
@@ -66,19 +67,19 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
if (WebPGetInfo(filedata,size, &width, &height) == 0) {
zend_error(E_ERROR, "gd-webp cannot get webp info");
- gdFree(temp);
+ gdFree(filedata);
return NULL;
}
im = gdImageCreateTrueColor(width, height);
if (!im) {
- gdFree(temp);
+ gdFree(filedata);
return NULL;
}
argb = WebPDecodeARGB(filedata, size, &width, &height);
if (!argb) {
zend_error(E_ERROR, "gd-webp cannot allocate temporary buffer");
- gdFree(temp);
+ gdFree(filedata);
gdImageDestroy(im);
return NULL;
}
@@ -94,7 +95,6 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile)
gdFree(filedata);
/* do not use gdFree here, in case gdFree/alloc is mapped to something else than libc */
free(argb);
- gdFree(temp);
im->saveAlphaFlag = 1;
return im;
}