summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-08-21 19:49:57 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2016-08-21 19:55:09 +0200
commit5347246f562729d0cb179e4aa00f831ca2af7173 (patch)
tree61811837316d17d71c4553c408f83c40b88c62f8
parent096b0a556cb40dc1eb8c8caaa3140dad5202b0f1 (diff)
parent4c13a7f5c4d0fcbfdd6cd60d84bc88f7c34bfb4f (diff)
downloadphp-git-5347246f562729d0cb179e4aa00f831ca2af7173.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
-rw-r--r--NEWS1
-rw-r--r--ext/gd/gd.c23
2 files changed, 22 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 00250e1057..d3e6e9f12b 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP NEWS
images). (cmb)
. Fixed bug #72913 (imagecopy() loses single-color transparency on palette
images). (cmb)
+ . Fixed bug #68716 (possible resource leaks in _php_image_convert()). (cmb)
- Reflection:
. Reverted prepending \ for class names and ? for nullable types returned
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index d2655a6022..bd5af9004a 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -4071,6 +4071,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
dest = VCWD_FOPEN(fn_dest, "wb");
if (!dest) {
php_error_docref(NULL, E_WARNING, "Unable to open '%s' for writing", fn_dest);
+ fclose(org);
RETURN_FALSE;
}
@@ -4079,6 +4080,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
im_org = gdImageCreateFromGif(org);
if (im_org == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to open '%s' Not a valid GIF file", fn_dest);
+ fclose(org);
+ fclose(dest);
RETURN_FALSE;
}
break;
@@ -4089,6 +4092,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
im_org = gdImageCreateFromJpegEx(org, ignore_warning);
if (im_org == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to open '%s' Not a valid JPEG file", fn_dest);
+ fclose(org);
+ fclose(dest);
RETURN_FALSE;
}
break;
@@ -4099,6 +4104,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
im_org = gdImageCreateFromPng(org);
if (im_org == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to open '%s' Not a valid PNG file", fn_dest);
+ fclose(org);
+ fclose(dest);
RETURN_FALSE;
}
break;
@@ -4106,10 +4113,14 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
default:
php_error_docref(NULL, E_WARNING, "Format not supported");
+ fclose(org);
+ fclose(dest);
RETURN_FALSE;
break;
}
+ fclose(org);
+
org_width = gdImageSX (im_org);
org_height = gdImageSY (im_org);
@@ -4140,6 +4151,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
im_tmp = gdImageCreate (dest_width, dest_height);
if (im_tmp == NULL ) {
php_error_docref(NULL, E_WARNING, "Unable to allocate temporary buffer");
+ fclose(dest);
+ gdImageDestroy(im_org);
RETURN_FALSE;
}
@@ -4147,23 +4160,29 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
gdImageDestroy(im_org);
- fclose(org);
-
im_dest = gdImageCreate(dest_width, dest_height);
if (im_dest == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to allocate destination buffer");
+ fclose(dest);
+ gdImageDestroy(im_tmp);
RETURN_FALSE;
}
white = gdImageColorAllocate(im_dest, 255, 255, 255);
if (white == -1) {
php_error_docref(NULL, E_WARNING, "Unable to allocate the colors for the destination buffer");
+ fclose(dest);
+ gdImageDestroy(im_tmp);
+ gdImageDestroy(im_dest);
RETURN_FALSE;
}
black = gdImageColorAllocate(im_dest, 0, 0, 0);
if (black == -1) {
php_error_docref(NULL, E_WARNING, "Unable to allocate the colors for the destination buffer");
+ fclose(dest);
+ gdImageDestroy(im_tmp);
+ gdImageDestroy(im_dest);
RETURN_FALSE;
}