1. libgd
  2. Untitled project
  3. gd-libgd
  4. Issues

Issues

Issue #21 resolved

gdImageFilledRectangle can take very long time with rects outside of image

Gabriel Schreiber
created an issue

There is an (arguable) bug in gdImageFilledRectangle:

If you call it with a rect outside of the image bounds it may take surprisingly long depending on the position. The user would expect that the performance does not depent on the position of the rect.

Consider the arguments: x1=-2147483648, y1=57, x2=-2147483644, y2=65 The function clips x1 and y2 to the image, but not x2 and y2. This sets the parameters to x1=0, y1=57, x2=-2147483644, y2=65 Then it swaps x1/x2 if needed, setting to parameters to x1=-2147483644, y1=57, x2=0, y2=65 This leads to an iteration from -2147483644 to 0.

Clipping needs to be done on x2 and y2 also in "gd.c" line 2400ff.

Comments (1)

  1. Log in to comment