]> granicus.if.org Git - php/commitdiff
- MFH bug #27582 (imagefilltoborder crashes)
authorPierre Joye <pajoye@php.net>
Sat, 13 Mar 2004 23:36:29 +0000 (23:36 +0000)
committerPierre Joye <pajoye@php.net>
Sat, 13 Mar 2004 23:36:29 +0000 (23:36 +0000)
ext/gd/libgd/gd.c
ext/gd/tests/bug27582_1.phpt [new file with mode: 0644]

index e7edf128808ea375985c8be4deb15f93b9f17715..a800aa8397a15246c3a93082f4518527e3060e5d 100644 (file)
@@ -1769,6 +1769,11 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
                return;
        }
 
+       if (im->alphaBlendingFlag) {
+               restoreAlphaBleding = 1;
+               im->alphaBlendingFlag = 0;
+       }
+
        if (x >= im->sx) {
                x = im->sx - 1;
        }
@@ -1784,6 +1789,9 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
                leftLimit = i;
        }
        if (leftLimit == -1) {
+               if (restoreAlphaBleding) {
+                       im->alphaBlendingFlag = 1;
+               }
                return;
        }
        /* Seek right */
@@ -1827,6 +1835,9 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
                        }
                }
        }
+       if (restoreAlphaBleding) {
+               im->alphaBlendingFlag = 1;
+       }
 }
 
 
diff --git a/ext/gd/tests/bug27582_1.phpt b/ext/gd/tests/bug27582_1.phpt
new file mode 100644 (file)
index 0000000..6dee785
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+gdimagefill() function (Bug #19366 (fixed in bundled libgd))
+--SKIPIF--
+<?php
+        if (!extension_loaded('gd')) die("skip gd extension not available\n");
+        if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+/* $id$ */
+$dest = dirname(realpath(__FILE__)) . 'bug27582.png';
+@unlink($dest);
+$im = ImageCreateTrueColor(10, 10);
+imagealphablending($im, true);
+imagesavealpha($im, false);
+$bordercolor=ImageColorAllocateAlpha($im, 0, 0, 0, 2);
+$color = ImageColorAllocateAlpha($im, 0, 0, 0, 1);
+ImageFillToBorder($im, 5, 5, $bordercolor, $color);
+imagepng($im, $dest);
+echo md5_file($dest) . "\n";
+?>
+--EXPECT--
+08287f8f5d406946009df5f04ca83dc0