php.net |  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
Description:
------------
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:
---------------
<?php
  $img = imagecreatefromjpeg('test.jpg');
  ImageTrueColorToPalette($img, false, 0);
?>

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

Actual result:
--------------
Segmentation fault


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-26 23:37 UTC] tony2001@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 15:02:26 2014 UTC