Skip to content

Commit

Permalink
Merge branch 'PHP-7.0' into PHP-7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cmb69 committed Sep 24, 2016
2 parents 394e9b3 + 5c81298 commit c733f92
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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)

- JSON:
. Fixed bug #73113 (Segfault with throwing JsonSerializable). (julien)
Expand Down
10 changes: 5 additions & 5 deletions ext/gd/libgd/gd_gd2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Binary file added ext/gd/tests/bug73161.gd2
Binary file not shown.
18 changes: 18 additions & 0 deletions ext/gd/tests/bug73161.phpt
Original file line number Diff line number Diff line change
@@ -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===

0 comments on commit c733f92

Please sign in to comment.