|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34996 ImageTrueColorToPalette crashes when ncolors is zero
Submitted: 2005-10-26 23:05 UTC Modified: 2005-10-26 23:37 UTC
From: php at eder dot us Assigned:
Status: Closed Package: GD related
PHP Version: 5.0.5 OS: FC 4, FreeBSD 5.3
Private report: No CVE-ID:
 [2005-10-26 23:05 UTC] php at eder dot us
When ImageTrueColorToPalette is called with ncolors = to zero (or an uninitialized variable), it segfaults.

Note: if $img is not loaded with a valid jpg, it will not crash, simply error on bad image resource.  So make sure 'test.jpg' points to a valid jpeg.

Reproduce code:
  $img = imagecreatefromjpeg('test.jpg');
  ImageTrueColorToPalette($img, false, 0);

Expected result:
No expected output, simply $img should be an indexed image.

Actual result:
Segmentation fault


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-26 23:37 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sun Oct 04 03:01:29 2015 UTC