@pajoye, This is a reminder that this bug is still open, since a new release is coming in two days (and it's probably the last release for 5.5), also please remember #72494 :) sorry for the noise.
Thanks!

Hi Fernando,
Patch has been applied.
Howwvrr i had to revert it for 5.6 because the behaviour of the line clipping seems to differ and we still end up with OOB. Same code does not oob read/write in 7.0/5.5/master.
I will investigate it further in the next couple of days.

Well, actually this issue may also affect imageline(), because
clip_1d() expects the maxdim to be the largest value that is
inside the image/clipping boundary. An image that is 10 pixels
large, may only draw from 0 to 9 (inclusive). Therefore the
respective code in gdImageLine() should be adjusted to pass
gdImageSX(im)-1 resp. gdImageSY(im)-1. This is not stricly
necessary, however, because normal line drawing calls
gdImageSetPixel() only if gdImageBoundsSafe() succeeds.
The suggested patch for gdImageAALine()[1] is insufficient,
because antialiased pixels are not checked with
gdImageBoundsSafe() (except for master). There, subtracting 1 from
the image dimensions is mandatory.
The attached patch fixes both issues, and besides including a
regression test for antialiased line drawing, includes also a test
that shows that subtracting 1 from the image dimensions when
calling clip_1d() does not affect normal line drawing.
[1] <http://git.php.net/?p=php-src.git;a=commit;h=b25009fc2c97c6b5a93b3fc5f6a5b221b62f1273>