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