diff --git a/ext/gd/libgd/gd_gd2.c b/ext/gd/libgd/gd_gd2.c index e954aafa680..3b4dfbe098a 100644 --- a/ext/gd/libgd/gd_gd2.c +++ b/ext/gd/libgd/gd_gd2.c @@ -689,8 +689,8 @@ static void _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt) } /* Work out number of chunks. */ - ncx = im->sx / cs + 1; - ncy = im->sy / cs + 1; + ncx = (im->sx + cs - 1) / cs; + ncy = (im->sy + cs - 1) / cs; /* Write the standard header. */ _gd2PutHeader (im, out, cs, fmt, ncx, ncy); diff --git a/ext/gd/tests/bug73155.phpt b/ext/gd/tests/bug73155.phpt new file mode 100644 index 00000000000..dc1791e565f --- /dev/null +++ b/ext/gd/tests/bug73155.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #73155 (imagegd2() writes wrong chunk sizes on boundaries) +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +chunk size: 64 +x chunk count: 1 +y chunk count: 1 +file size: 5145 +===DONE===