|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-01-08 13:47 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2018-01-08 13:47 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 23:00:01 2025 UTC |
Description: ------------ Corrupt PNG image causes non-recoverable fatal PHP error. PHP Fatal error: imagecreatefrompng(): gd-png: fatal libpng error: Read Error Also affected: PHP 7.0.26 PHP 7.1.13 PHP 7.2.1 Test script: --------------- <?php ini_set('display_errors', 1); #actual image location: http://www.knoraki.se/media/ACME_191101_440x440_1.png echo print_r(gd_info(), true); $image = false; $filename = 'ACME_191101_440x440_1.png'; $image = imagecreatefrompng($filename); //$image = getimagesize($filename); if (!$image) { $image = 'failed'; } echo print_r($image, true); Expected result: ---------------- Array ( [GD Version] => bundled (2.1.0 compatible) [FreeType Support] => 1 [FreeType Linkage] => with freetype [T1Lib Support] => [GIF Read Support] => 1 [GIF Create Support] => 1 [JPEG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => 1 [XBM Support] => 1 [WebP Support] => 1 [JIS-mapped Japanese Font Support] => ) Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncate d data in D:\Bill-Data\tmp\php-gd-bug\image-test.php on line 8 Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in D :\Bill-Data\tmp\php-gd-bug\image-test.php on line 8 Warning: imagecreatefrompng(): 'ACME_191101_440x440_1.png' is not a valid PNG fi le in D:\Bill-Data\tmp\php-gd-bug\image-test.php on line 8 failed Actual result: -------------- root@vmi137424:/var/www/magento.eabi.ee/php-gd-bug# php7.1 image-test.php Array ( [GD Version] => 2.2.4 [FreeType Support] => 1 [FreeType Linkage] => with freetype [GIF Read Support] => 1 [GIF Create Support] => 1 [JPEG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => 1 [XBM Support] => 1 [WebP Support] => 1 [JIS-mapped Japanese Font Support] => ) PHP Fatal error: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data in /var/www/magento.eabi.ee/php-gd-bug/image-test.php on line 8 Fatal error: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data in /var/www/magento.eabi.ee/php-gd-bug/image-test.php on line 8 #notice how the final "failed" statement is not displayed because the script is halted.