++colors;
}
}
+ if (colors == 0) {
+ php_gd_error("gd-png error: no colors in palette");
+ goto bail;
+ }
if (colors < im->colorsTotal) {
remap = TRUE;
}
}
}
/* 1.6.3: maybe we should give that memory BACK! TBB */
+ bail:
png_destroy_write_struct(&png_ptr, &info_ptr);
}
--- /dev/null
+--TEST--
+Bug #45799 (imagepng() crashes on empty image).
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+?>
+--FILE--
+<?php
+$img = imagecreate(500,500);
+imagepng($img);
+imagedestroy($img);
+?>
+--EXPECTF--
+
+Warning: imagepng(): gd-png error: no colors in palette in %s on line %d