Skip to content

Commit 55001de

Browse files
smalyshevJulien Pauli
authored andcommitted
Fix bug #68799: Free called on unitialized pointer
1 parent 6735df1 commit 55001de

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

ext/exif/exif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
27022702
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
27032703
{
27042704
xp_field->tag = tag;
2705-
2705+
xp_field->value = NULL;
27062706
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
27072707
if (zend_multibyte_encoding_converter(
27082708
(unsigned char**)&xp_field->value,

ext/exif/tests/bug68799.jpg

735 Bytes
Loading

ext/exif/tests/bug68799.phpt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
--TEST--
2+
Bug #68799 (Free called on unitialized pointer)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
/*
8+
* Pollute the heap. Helps trigger bug. Sometimes not needed.
9+
*/
10+
class A {
11+
function __construct() {
12+
$a = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa';
13+
$this->a = $a . $a . $a . $a . $a . $a;
14+
}
15+
};
16+
17+
function doStuff ($limit) {
18+
19+
$a = new A;
20+
21+
$b = array();
22+
for ($i = 0; $i < $limit; $i++) {
23+
$b[$i] = clone $a;
24+
}
25+
26+
unset($a);
27+
28+
gc_collect_cycles();
29+
}
30+
31+
$iterations = 3;
32+
33+
doStuff($iterations);
34+
doStuff($iterations);
35+
36+
gc_collect_cycles();
37+
38+
print_r(exif_read_data(__DIR__.'/bug68799.jpg'));
39+
40+
?>
41+
--EXPECTF--
42+
Array
43+
(
44+
[FileName] => bug68799.jpg
45+
[FileDateTime] => %d
46+
[FileSize] => 735
47+
[FileType] => 2
48+
[MimeType] => image/jpeg
49+
[SectionsFound] => ANY_TAG, IFD0, WINXP
50+
[COMPUTED] => Array
51+
(
52+
[html] => width="1" height="1"
53+
[Height] => 1
54+
[Width] => 1
55+
[IsColor] => 1
56+
[ByteOrderMotorola] => 1
57+
)
58+
59+
[XResolution] => 96/1
60+
[YResolution] => 96/1
61+
[ResolutionUnit] => 2
62+
[Author] =>
63+
)

0 commit comments

Comments
 (0)