diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 474d3b00e28..b4278316726 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -2046,7 +2046,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 00000000000..24db8024fe3 --- /dev/null +++ b/ext/gd/tests/bug53156.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #53156 (imagerectangle problem with point ordering) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++ +Rectangle: ++++