summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-09-24 12:39:56 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2016-09-24 12:41:48 +0200
commit5c81298597f291f7785d9f0ff2c331b4c53ced6c (patch)
tree5a008b6aaf0c63958f54b6c3be2030911cda701a
parent61722743f455743b096f38c5f9e6944aa00dcd6a (diff)
parent8f5eda4bf62ca0e1ba6459b42fb5c0b629774cb2 (diff)
downloadphp-git-5c81298597f291f7785d9f0ff2c331b4c53ced6c.tar.gz
Merge branch 'PHP-5.6' into PHP-7.0
-rw-r--r--NEWS1
-rw-r--r--ext/gd/libgd/gd_gd2.c10
-rw-r--r--ext/gd/tests/bug73161.gd2bin0 -> 26 bytes
-rw-r--r--ext/gd/tests/bug73161.phpt18
4 files changed, 24 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 46fddef86f..6bff08b6a0 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,7 @@ PHP NEWS
. Fixed bug #73155 (imagegd2() writes wrong chunk sizes on boundaries). (cmb)
. Fixed bug #73159 (imagegd2(): unrecognized formats may result in corrupted
files). (cmb)
+ . Fixed bug #73161 (imagecreatefromgd2() may leak memory). (cmb)
- Mbstring:
. Fixed bug #66797 (mb_substr only takes 32-bit signed integer). (cmb)
diff --git a/ext/gd/libgd/gd_gd2.c b/ext/gd/libgd/gd_gd2.c
index 57d5844510..d06f328425 100644
--- a/ext/gd/libgd/gd_gd2.c
+++ b/ext/gd/libgd/gd_gd2.c
@@ -191,21 +191,21 @@ static gdImagePtr _gd2CreateFromFile (gdIOCtxPtr in, int *sx, int *sy, int *cs,
}
if (im == NULL) {
GD2_DBG(php_gd_error("Could not create gdImage"));
- goto fail1;
+ goto fail2;
}
if (!_gdGetColors(in, im, (*vers) == 2)) {
GD2_DBG(php_gd_error("Could not read color palette"));
- goto fail2;
+ goto fail3;
}
GD2_DBG(php_gd_error("Image palette completed: %d colours", im->colorsTotal));
return im;
-fail2:
+fail3:
gdImageDestroy(im);
- return 0;
-
+fail2:
+ gdFree(*cidx);
fail1:
return 0;
}
diff --git a/ext/gd/tests/bug73161.gd2 b/ext/gd/tests/bug73161.gd2
new file mode 100644
index 0000000000..f5084e4976
--- /dev/null
+++ b/ext/gd/tests/bug73161.gd2
Binary files differ
diff --git a/ext/gd/tests/bug73161.phpt b/ext/gd/tests/bug73161.phpt
new file mode 100644
index 0000000000..42ad718606
--- /dev/null
+++ b/ext/gd/tests/bug73161.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #73161 (imagecreatefromgd2() may leak memory)
+--DESCRIPTION--
+We're testing for a memory leak that might not even show up with valgrind.
+--SKIPIF--
+<?php
+if (!extension_loaded('gd')) die('skip gd extension not available');
+?>
+--FILE--
+<?php
+$im = imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73161.gd2');
+var_dump($im);
+?>
+===DONE===
+--EXPECTF--
+Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
+bool(false)
+===DONE===