imagepng() crashes on empty image
| Bug #45799 | imagepng() crashes on empty image | ||||
|---|---|---|---|---|---|
| Submitted: | 2008-08-12 13:29 UTC | Modified: | 2009-03-14 16:34 UTC | ||
| From: | amelek32 at gmail dot com | Assigned: | pajoye (profile) | ||
| Status: | Closed | Package: | GD related | ||
| PHP Version: | 5.2.8, 5.3CVS, 6CVS (2008-12-09) | OS: | * | ||
| Private report: | No | CVE-ID: | None | ||
[2008-08-12 13:29 UTC] amelek32 at gmail dot com
Description:
------------
imagepng *crashes* when no color was alocated.
I see no point in rendering blank images, but this functions behavior is buggy.
All other functions (imagejpeg, imagegif) AND imagepng on true scale images return black image. This is most likely expected result.
Instead, this function flushes some part of header and then crashes with warnings when trying to convert non existing color palette.
GD Version bundled (2.0.34 compatible)
Reproduce code:
---------------
<?
$img = imagecreate(500,500);
//header("Content-type: image/png"); // skip this to see the problem, else browser will ignore corrupted image.
imagepng($img);
imagedestroy($img);
?>
Expected result:
----------------
blank black image (like other image* functions) or E_WARNING without junk.
Actual result:
--------------
?PNG IHDR???M?
Warning: imagepng() [function.imagepng]: gd-png: fatal libpng error: Invalid number of colors in palette in C:\usr\apache\httpd\html\draw.php on line 21
Warning: imagepng() [function.imagepng]: gd-png error: setjmp returns error condition in C:\usr\apache\httpd\html\draw.php on line 21
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2008-08-12 13:37 UTC] pajoye@php.net
[2008-08-12 13:45 UTC] amelek32 at gmail dot com
[2008-08-12 14:25 UTC] pajoye@php.net
[2008-11-30 22:52 UTC] pajoye@php.net
[2008-12-01 11:00 UTC] amelek32 at gmail dot com
[2009-03-14 16:34 UTC] tabe@php.net