From 72b73e24a00b9872214fbcc256ee38431d9c9d47 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 20 Jul 2015 02:11:18 +0200 Subject: [PATCH] Fix #53156: imagerectangle problem with point ordering Contrary to imagefilledrectangle(), imagerectangle() has the documented limitation that the given points have to be the upper left and the lower right corner, respectively. However, libgd already caters to upper right / lower left pairs, and not catering to the other two combinations seems to be an oversight. --- ext/gd/libgd/gd.c | 4 ++- ext/gd/tests/bug53156.phpt | 59 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 ext/gd/tests/bug53156.phpt diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index c75c985c4e..f03fd0278a 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -2044,7 +2044,9 @@ void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) t=y1; y1 = y2; y2 = t; - + } + + if (x2 < x1) { t = x1; x1 = x2; x2 = t; diff --git a/ext/gd/tests/bug53156.phpt b/ext/gd/tests/bug53156.phpt new file mode 100644 index 0000000000..a269369670 --- /dev/null +++ b/ext/gd/tests/bug53156.phpt @@ -0,0 +1,59 @@ +--TEST-- +Bug #53156 (imagerectangle problem with point ordering) +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECT-- +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ -- 2.40.0