File tree 3 files changed +37
-1
lines changed
3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ PHP NEWS
30
30
. Fixed bug GH-17643 (FPM with httpd ProxyPass encoded PATH_INFO env).
31
31
(Jakub Zelenka)
32
32
33
+ - GD:
34
+ . Fixed bug GH-17772 (imagepalettetotruecolor crash with memory_limit=2M).
35
+ (David Carlier)
36
+
33
37
- LDAP:
34
38
. Fixed bug GH-17704 (ldap_search fails when $attributes contains a
35
39
non-packed array with numerical keys). (nielsdos, 7u83)
Original file line number Diff line number Diff line change @@ -3162,7 +3162,11 @@ int gdImagePaletteToTrueColor(gdImagePtr src)
3162
3162
const unsigned int sy = gdImageSY (src );
3163
3163
const unsigned int sx = gdImageSX (src );
3164
3164
3165
- src -> tpixels = (int * * ) gdMalloc (sizeof (int * ) * sy );
3165
+ // Note: do not revert back to gdMalloc() below ; reason here,
3166
+ // due to a bug with a certain memory_limit INI value treshold,
3167
+ // imagepalettetotruecolor crashes with even unrelated ZendMM allocations.
3168
+ // See GH-17772 for an use case.
3169
+ src -> tpixels = (int * * ) gdCalloc (sizeof (int * ), sy );
3166
3170
if (src -> tpixels == NULL ) {
3167
3171
return 0 ;
3168
3172
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-17772 (imagepalettetotruecolor segfault on image deallocation)
3
+ --EXTENSIONS--
4
+ gd
5
+ --INI--
6
+ memory_limit=2M
7
+ --CREDITS--
8
+ YuanchengJiang
9
+ --SKIPIF--
10
+ <?php
11
+ if (!GD_BUNDLED ) die ("skip requires bundled GD library " );
12
+ ?>
13
+ --FILE--
14
+ <?php
15
+ function setStyleAndThickness ($ im , $ color , $ thickness )
16
+ {
17
+ $ arr = [];
18
+ $ i = 0 ;
19
+ while ($ i < 16 * $ thickness ) {
20
+ $ arer [$ i ++] = $ color ;
21
+ }
22
+ }
23
+ $ im = imagecreate (800 , 800 );
24
+ setStyleAndThickness ($ im , 0 , 6 );
25
+ imagepalettetotruecolor ($ im );
26
+ ?>
27
+ --EXPECTF--
28
+ Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
You can’t perform that action at this time.
0 commit comments