mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix bug #68799: Free called on unitialized pointer
This commit is contained in:
parent
f9ad308669
commit
2fc178cf44
3 changed files with 64 additions and 1 deletions
|
@ -2702,7 +2702,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
|
||||||
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
|
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount TSRMLS_DC)
|
||||||
{
|
{
|
||||||
xp_field->tag = tag;
|
xp_field->tag = tag;
|
||||||
|
xp_field->value = NULL;
|
||||||
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
|
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
|
||||||
if (zend_multibyte_encoding_converter(
|
if (zend_multibyte_encoding_converter(
|
||||||
(unsigned char**)&xp_field->value,
|
(unsigned char**)&xp_field->value,
|
||||||
|
|
BIN
ext/exif/tests/bug68799.jpg
Normal file
BIN
ext/exif/tests/bug68799.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 735 B |
63
ext/exif/tests/bug68799.phpt
Normal file
63
ext/exif/tests/bug68799.phpt
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #68799 (Free called on unitialized pointer)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Pollute the heap. Helps trigger bug. Sometimes not needed.
|
||||||
|
*/
|
||||||
|
class A {
|
||||||
|
function __construct() {
|
||||||
|
$a = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa';
|
||||||
|
$this->a = $a . $a . $a . $a . $a . $a;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function doStuff ($limit) {
|
||||||
|
|
||||||
|
$a = new A;
|
||||||
|
|
||||||
|
$b = array();
|
||||||
|
for ($i = 0; $i < $limit; $i++) {
|
||||||
|
$b[$i] = clone $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($a);
|
||||||
|
|
||||||
|
gc_collect_cycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
$iterations = 3;
|
||||||
|
|
||||||
|
doStuff($iterations);
|
||||||
|
doStuff($iterations);
|
||||||
|
|
||||||
|
gc_collect_cycles();
|
||||||
|
|
||||||
|
print_r(exif_read_data(__DIR__.'/bug68799.jpg'));
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Array
|
||||||
|
(
|
||||||
|
[FileName] => bug68799.jpg
|
||||||
|
[FileDateTime] => %d
|
||||||
|
[FileSize] => 735
|
||||||
|
[FileType] => 2
|
||||||
|
[MimeType] => image/jpeg
|
||||||
|
[SectionsFound] => ANY_TAG, IFD0, WINXP
|
||||||
|
[COMPUTED] => Array
|
||||||
|
(
|
||||||
|
[html] => width="1" height="1"
|
||||||
|
[Height] => 1
|
||||||
|
[Width] => 1
|
||||||
|
[IsColor] => 1
|
||||||
|
[ByteOrderMotorola] => 1
|
||||||
|
)
|
||||||
|
|
||||||
|
[XResolution] => 96/1
|
||||||
|
[YResolution] => 96/1
|
||||||
|
[ResolutionUnit] => 2
|
||||||
|
[Author] =>
|
||||||
|
)
|
Loading…
Add table
Add a link
Reference in a new issue