php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48179 imagecreatefromjpeg() crashes i.s.o. return FALSE
Submitted: 2009-05-07 12:45 UTC Modified: 2009-05-07 13:17 UTC
From: ronald dot muller at gmail dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID: None
 [2009-05-07 12:45 UTC] ronald dot muller at gmail dot com
Description:
------------
imagecreatefromjpeg() should return FALSE on errors (as documented), not crash - hence aborting the php script.

http://www.plasticdaisy.net/dlvs/dlvs.php?c=pr
shows "Fatal error: Allowed memory size of 33554432 bytes exhausted" and aborts the script.

The crash occurs because memory_limit is exceeded, as mentioned in previous submissions on the same bug. In the example case a 3.8MB jpg is expanded internally to somewhere in between 32MB and 64MB. Increasing the memory_limit does not solve the bug, it merely hides it again. The function should be made according to spec, i.e. return FALSE. Then the php script can act properly on this error.

Reproduce code:
---------------
ini_set('memory_limit', $TOO_SMALL);

$someVar = imagecreatefromjpeg($img);

echo $someVar;

Expected result:
----------------
return FALSE i.s.o. crash, as documented.

Actual result:
--------------
Fatal error: Allowed memory size of 33554432 bytes exhausted

http://www.plasticdaisy.net/dlvs/dlvs.php?c=pr

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-07 13:08 UTC] ronald dot muller at gmail dot com
new example url:
http://www.plasticdaisy.net/dlvs/pr/index.php

reports:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13056 bytes) in /mounted-storage/home6a/sub004/sc11402-FHCV/www/dlvs/pr/index.php on line 5

script contains following lines:
<?php

ini_set('memory_limit', '8M');

$someVar = imagecreatefromjpeg('P5011513.JPG');

echo $someVar;


?>
 [2009-05-07 13:17 UTC] jani@php.net
To be able to read huge images you just have to increase the 
memory_limit. There is no other fix for this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 21:01:29 2024 UTC