diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 5096f69001b9..c0bf6f789159 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -4395,7 +4395,7 @@ static bool exif_read_from_impl(image_info_type *ImageInfo, php_stream *stream, ImageInfo->FileName = NULL; if (php_stream_is(ImageInfo->infile, PHP_STREAM_IS_STDIO)) { - if (VCWD_STAT(stream->orig_path, &st) >= 0) { + if (stream->orig_path && VCWD_STAT(stream->orig_path, &st) >= 0) { zend_string *base; if ((st.st_mode & S_IFMT) != S_IFREG) { exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Not a file"); diff --git a/ext/exif/tests/gh16409.phpt b/ext/exif/tests/gh16409.phpt new file mode 100644 index 000000000000..c2c54d839e01 --- /dev/null +++ b/ext/exif/tests/gh16409.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-16409 (Segfault in exif_thumbnail when not dealing with a real file) +--EXTENSIONS-- +exif +--FILE-- + +--EXPECTF-- +Warning: exif_thumbnail(): File too small (0) in %s on line %d +bool(false)%A