diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index c75c985c4ef8f..f03fd0278a63b 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 0000000000000..24db8024fe344 --- /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: ++++