|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77195 Incorrect error handling of imagecreatefromjpeg function with corrupt jpeg
Submitted: 2018-11-23 15:11 UTC Modified: 2018-11-23 23:16 UTC
From: Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2018-11-23 15:11 UTC]
The imagecreatefromjpeg function improperly handles errors when passing a corrupt jpeg image.

Not only does it still output an error (coming from gd directly I guess), but it also spits out 3 PHP errors (1 notice and 2 warnings).

Test script:
Test image can be found at



Expected result:
First call with the STFU operator should output nothing.

Second call without the STFU operators should probably just give one single php error instead of 3

Actual result:
First call with the STFU operator:

JPEG datastream contains no image

Second call without the STFU operator:

PHP Notice:  imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 947 extraneous bytes before marker 0xd9
 in /path/to/test.php on line 5
PHP Warning:  imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error:  in /path/to/test.php on line 5
JPEG datastream contains no image
PHP Warning:  imagecreatefromjpeg(): '/path/to/image/broken-mspaint.jpeg' is not a valid JPEG file in /path/to/test.php on line 5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-23 17:42 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2018-11-23 17:42 UTC]
This looks like a duplicate of bug #75888.
 [2018-11-23 20:00 UTC]
How is this a dupe?

I am getting unexpected output (even when using the STFU operator).

The dupe is about getting an unexpected fatal error.

Am I missing something here?
 [2018-11-23 20:10 UTC]
Also note I am using the bundled gd lib
 [2018-11-23 23:16 UTC]
-Status: Duplicate +Status: Open
 [2018-11-23 23:16 UTC]
> Also note I am using the bundled gd lib

Ah, then the other ticket is certainly unrelated.
 [2018-11-24 12:02 UTC]
Automatic comment on behalf of
Log: Fix #77195: Incorrect error handling of imagecreatefromjpeg()
 [2018-11-24 12:02 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 12 22:01:30 2024 UTC