Skip to content

Commit 4546b87

Browse files
committed
ext/exif: Minor refactoring of exif_read_data()
1 parent 4a8cd31 commit 4546b87

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ext/exif/exif.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4699,7 +4699,6 @@ PHP_FUNCTION(exif_read_data)
46994699
PHP_FUNCTION(exif_thumbnail)
47004700
{
47014701
bool ret;
4702-
int arg_c = ZEND_NUM_ARGS();
47034702
image_info_type ImageInfo;
47044703
zval *stream;
47054704
zval *z_width = NULL, *z_height = NULL, *z_imagetype = NULL;
@@ -4731,7 +4730,7 @@ PHP_FUNCTION(exif_thumbnail)
47314730
RETURN_THROWS();
47324731
}
47334732

4734-
if (CHECK_NULL_PATH(Z_STRVAL_P(stream), Z_STRLEN_P(stream))) {
4733+
if (zend_str_has_nul_byte(Z_STR_P(stream))) {
47354734
zend_argument_value_error(1, "must not contain any null bytes");
47364735
RETURN_THROWS();
47374736
}
@@ -4756,8 +4755,8 @@ PHP_FUNCTION(exif_thumbnail)
47564755
exif_error_docref(NULL EXIFERR_CC, &ImageInfo, E_NOTICE, "Returning thumbnail(%d)", ImageInfo.Thumbnail.size);
47574756
#endif
47584757

4759-
ZVAL_STRINGL(return_value, ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size);
4760-
if (arg_c >= 3) {
4758+
RETVAL_STRINGL(ImageInfo.Thumbnail.data, ImageInfo.Thumbnail.size);
4759+
if (z_height) {
47614760
if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) {
47624761
if (!exif_scan_thumbnail(&ImageInfo)) {
47634762
ImageInfo.Thumbnail.width = ImageInfo.Thumbnail.height = 0;
@@ -4766,7 +4765,7 @@ PHP_FUNCTION(exif_thumbnail)
47664765
ZEND_TRY_ASSIGN_REF_LONG(z_width, ImageInfo.Thumbnail.width);
47674766
ZEND_TRY_ASSIGN_REF_LONG(z_height, ImageInfo.Thumbnail.height);
47684767
}
4769-
if (arg_c >= 4) {
4768+
if (z_imagetype) {
47704769
ZEND_TRY_ASSIGN_REF_LONG(z_imagetype, ImageInfo.Thumbnail.filetype);
47714770
}
47724771

0 commit comments

Comments
 (0)