summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-05-22 09:22:38 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-05-22 09:22:38 +0200
commit7f51f435097df83af3d39bd088cb17f15ae970a0 (patch)
tree35bea65e72bb5571ccc94ae8534ca18ffd2f9cf1
parentbb1a68b40c90612d21e2a416e6658dc044d19f30 (diff)
parentda801ba5e3553f4c217d2528b36a5977ee9a90ed (diff)
downloadphp-git-7f51f435097df83af3d39bd088cb17f15ae970a0.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79615: Wrong GIF header written in GD GIFEncode
-rw-r--r--ext/gd/libgd/gd_gif_out.c2
-rw-r--r--ext/gd/tests/bug79615.phpt20
2 files changed, 21 insertions, 1 deletions
diff --git a/ext/gd/libgd/gd_gif_out.c b/ext/gd/libgd/gd_gif_out.c
index 912769128b..e721992b48 100644
--- a/ext/gd/libgd/gd_gif_out.c
+++ b/ext/gd/libgd/gd_gif_out.c
@@ -333,7 +333,7 @@ GIFEncode(gdIOCtxPtr fp, int GWidth, int GHeight, int GInterlace, int Background
/*
* OR in the resolution
*/
- B |= (Resolution - 1) << 5;
+ B |= (Resolution - 1) << 4;
/*
* OR in the Bits per Pixel
diff --git a/ext/gd/tests/bug79615.phpt b/ext/gd/tests/bug79615.phpt
new file mode 100644
index 0000000000..b7cf9175c5
--- /dev/null
+++ b/ext/gd/tests/bug79615.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #79615 (Wrong GIF header written in GD GIFEncode)
+--SKIPIF--
+<?php
+if (!extension_loaded('gd')) die('skip gd extension not available');
+?>
+--FILE--
+<?php
+$im = imagecreate(3, 3); // 3x3, 9 colors, 4 bits per pixel
+for ($x = 0; $x < 3; $x++) {
+ for ($y = 0; $y < 3; $y++) {
+ imagesetpixel($im, $x, $y, imagecolorallocate($im, $x, $y, 0));
+ }
+}
+ob_start();
+imagegif($im);
+echo decbin(ord(ob_get_clean()[0xA]));
+?>
+--EXPECT--
+10110011