#45799 [Asn->WFx]: imagepng() crashes on empty image

From: Date: Sun, 30 Nov 2008 22:52:48 +0000
Subject: #45799 [Asn->WFx]: imagepng() crashes on empty image
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131503@lists.php.net to get a copy of this message
ID: 45799 Updated by: pajoye@php.net Reported By: amelek32 at gmail dot com -Status: Assigned +Status: Wont fix Bug Type: GD related Operating System: Windows XP Pro x64 PHP Version: 5.2.6 Assigned To: pajoye New Comment: Well, after a 2nd look, the warning will remain anyway. Whether it is raised by libgd or php does not change anything > won't fix Previous Comments: ------------------------------------------------------------------------ [2008-08-12 14:25:05] pajoye@php.net > shouldn't it return warning without putting part of header to output? Hm, good point. I may add a check before calling the png function and avoid to much troubles later. I will do it for 5.3+ ------------------------------------------------------------------------ [2008-08-12 13:45:49] amelek32 at gmail dot com shouldn't it return warning without putting part of header to output? ------------------------------------------------------------------------ [2008-08-12 13:37:02] pajoye@php.net That's libpng behaviors. A PNG palette image must have colors to be saved. By the way, warnings are not crashes. ------------------------------------------------------------------------ [2008-08-12 13:29:36] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45799&edit=1

« previous php.bugs (#131503) next »