Skip to content

Commit 7f51f43

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79615: Wrong GIF header written in GD GIFEncode
2 parents bb1a68b + da801ba commit 7f51f43

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ext/gd/libgd/gd_gif_out.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ GIFEncode(gdIOCtxPtr fp, int GWidth, int GHeight, int GInterlace, int Background
333333
/*
334334
* OR in the resolution
335335
*/
336-
B |= (Resolution - 1) << 5;
336+
B |= (Resolution - 1) << 4;
337337

338338
/*
339339
* OR in the Bits per Pixel

ext/gd/tests/bug79615.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #79615 (Wrong GIF header written in GD GIFEncode)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) die('skip gd extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$im = imagecreate(3, 3); // 3x3, 9 colors, 4 bits per pixel
10+
for ($x = 0; $x < 3; $x++) {
11+
for ($y = 0; $y < 3; $y++) {
12+
imagesetpixel($im, $x, $y, imagecolorallocate($im, $x, $y, 0));
13+
}
14+
}
15+
ob_start();
16+
imagegif($im);
17+
echo decbin(ord(ob_get_clean()[0xA]));
18+
?>
19+
--EXPECT--
20+
10110011

0 commit comments

Comments
 (0)