Skip to content

Commit ecb1592

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Don't throw from imagecreatefromstring() with too short string
2 parents 2dcf71c + a89aaf6 commit ecb1592

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ext/gd/gd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,8 +1531,9 @@ PHP_FUNCTION(imagecreatefromstring)
15311531
}
15321532

15331533
if (ZSTR_LEN(data) < sizeof(sig)) {
1534-
zend_argument_value_error(1, "cannot be empty");
1535-
RETURN_THROWS();
1534+
/* Handle this the same way as an unknown image type. */
1535+
php_error_docref(NULL, E_WARNING, "Data is not in a recognized format");
1536+
RETURN_FALSE;
15361537
}
15371538

15381539
memcpy(sig, ZSTR_VAL(data), sizeof(sig));

ext/gd/tests/createfromstring.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ $im = imagecreatefromstring(' asdf jklp foo');
6262
--EXPECTF--
6363
createfromstring truecolor png: ok
6464
createfromstring palette png: ok
65-
imagecreatefromstring(): Argument #1 ($data) cannot be empty
6665

67-
Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d
66+
Warning: imagecreatefromstring(): Data is not in a recognized format in %s on line %d
67+
68+
Warning: imagecreatefromstring(): Data is not in a recognized format in %s on line %d

0 commit comments

Comments
 (0)