xref: /PHP-7.1/ext/exif/tests/bug68799.phpt (revision 59c2a55e)
1--TEST--
2Bug #68799 (Free called on uninitialized 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*/
10class A {
11    function __construct() {
12        $a = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa';
13        $this->a = $a . $a . $a . $a . $a . $a;
14    }
15};
16
17function 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
33doStuff($iterations);
34doStuff($iterations);
35
36gc_collect_cycles();
37
38print_r(exif_read_data(__DIR__.'/bug68799.jpg'));
39
40?>
41--EXPECTF--
42Array
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)
64