From: amelek32 at gmail dot com Operating system: Windows XP Pro x64 PHP version: 5.2.6 PHP Bug Type: GD related Bug description: imagepng() crashes on empty image
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 -- Edit bug report at http://bugs.php.net/?id=45799&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45799&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45799&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45799&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45799&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45799&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45799&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45799&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45799&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45799&r=support Expected behavior: http://bugs.php.net/fix.php?id=45799&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45799&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45799&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45799&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45799&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45799&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45799&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45799&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45799&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45799&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45799&r=mysqlcfg