From 83b8d2c290d24221e95c8fa1dc57a1b85f21fb70 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Sat, 12 Jul 2025 18:30:08 +0100 Subject: [PATCH] ext/gd: Fix comparison with result of php_stream_can_cast() Closes GH-19107 --- NEWS | 3 +++ ext/gd/gd.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 4bf10555b45..704398f5b6c 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,9 @@ PHP NEWS - FTP: . Fix theoretical issues with hrtime() not being available. (nielsdos) +- GD: + . Fix incorrect comparison with result of php_stream_can_cast(). (Girgias) + - Hash: . Fix crash on clone failure. (nielsdos) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 6b727a21118..cce2a5ca42f 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1566,7 +1566,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, pefree(pstr, 1); zend_string_release_ex(buff, 0); } - else if (php_stream_can_cast(stream, PHP_STREAM_AS_STDIO)) { + else if (php_stream_can_cast(stream, PHP_STREAM_AS_STDIO) == SUCCESS) { /* try and force the stream to be FILE* */ if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO | PHP_STREAM_CAST_TRY_HARD, (void **) &fp, REPORT_ERRORS)) { goto out_err;