Skip to content

Commit 14aa0e7

Browse files
committed
Fix exif crashes
1 parent bf0c196 commit 14aa0e7

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

TODO_SEGFAULTS

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ Fixed:
66

77
i18n_convert/mb_convert_encoding (Moriyoshi Koizumi)
88
socket_iovec_alloc (Rasmus)
9-
9+
exif_imagetype,exif_thumbnail (Rasmus)
1010

1111

1212
Open:
1313

1414
array_pad
1515
bcsub (1)
1616
dbase_open
17-
exif_imagetype
18-
exif_thumbnail
1917
mb_ereg (2)
2018
mb_ereg_match (2)
2119
mb_eregi (2)

ext/exif/exif.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4012,17 +4012,9 @@ PHP_FUNCTION(exif_thumbnail)
40124012
}
40134013

40144014
convert_to_string_ex(p_name);
4015-
if (arg_c >= 3) {
4016-
zval_dtor(*p_width);
4017-
zval_dtor(*p_height);
4018-
}
4019-
if (arg_c >= 4) {
4020-
zval_dtor(*p_imagetype);
4021-
}
40224015

40234016
ret = exif_read_file(&ImageInfo, Z_STRVAL_PP(p_name), 1, 0 TSRMLS_CC);
40244017
if (ret==FALSE) {
4025-
exif_discard_imageinfo(&ImageInfo);
40264018
RETURN_FALSE;
40274019
}
40284020

@@ -4043,10 +4035,13 @@ PHP_FUNCTION(exif_thumbnail)
40434035
if (!ImageInfo.Thumbnail.width || !ImageInfo.Thumbnail.height) {
40444036
exif_scan_thumbnail(&ImageInfo TSRMLS_CC);
40454037
}
4038+
zval_dtor(*p_width);
4039+
zval_dtor(*p_height);
40464040
ZVAL_LONG(*p_width, ImageInfo.Thumbnail.width);
40474041
ZVAL_LONG(*p_height, ImageInfo.Thumbnail.height);
40484042
}
40494043
if (arg_c >= 4) {
4044+
zval_dtor(*p_imagetype);
40504045
ZVAL_LONG(*p_imagetype, ImageInfo.Thumbnail.filetype);
40514046
}
40524047

@@ -4076,6 +4071,7 @@ PHP_FUNCTION(exif_imagetype)
40764071
if (zend_get_parameters_ex(1, &arg1) == FAILURE)
40774072
WRONG_PARAM_COUNT;
40784073

4074+
convert_to_string_ex(arg1);
40794075
stream = php_stream_open_wrapper(Z_STRVAL_PP(arg1), "rb", IGNORE_PATH|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
40804076

40814077
if (stream == NULL) {

0 commit comments

Comments
 (0)