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 @@ -18,6 +18,10 @@ PHP NEWS
18
18
. Fixed bug GH-17643 (FPM with httpd ProxyPass encoded PATH_INFO env).
19
19
(Jakub Zelenka)
20
20
21
+ - GD:
22
+ . Fixed bug GH-17772 (imagepalettetotruecolor crash with memory_limit=2M).
23
+ (David Carlier)
24
+
21
25
- LDAP:
22
26
. Fixed bug GH-17704 (ldap_search fails when $attributes contains a
23
27
non-packed array with numerical keys). (nielsdos, 7u83)
Original file line number Diff line number Diff line change @@ -3108,7 +3108,11 @@ int gdImagePaletteToTrueColor(gdImagePtr src)
3108
3108
const unsigned int sy = gdImageSY (src );
3109
3109
const unsigned int sx = gdImageSX (src );
3110
3110
3111
- src -> tpixels = (int * * ) gdMalloc (sizeof (int * ) * sy );
3111
+ // Note: do not revert back to gdMalloc() below ; reason here,
3112
+ // due to a bug with a certain memory_limit INI value treshold,
3113
+ // imagepalettetotruecolor crashes with even unrelated ZendMM allocations.
3114
+ // See GH-17772 for an use case.
3115
+ src -> tpixels = (int * * ) gdCalloc (sizeof (int * ), sy );
3112
3116
if (src -> tpixels == NULL ) {
3113
3117
return 0 ;
3114
3118
}
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