Package: libgd2-xpm
Severity: important
Tags: patch
In addition to my previous fixes for anti-aliased lines (bug #364024),
this corrects a segfault when you try and draw a short line outside
image bounds (so short it is really a pixel).
Attached is a test case and a patch that corrects the problem.
thanks, sorry I didn't get this out sooner,
Paul
-- System Information:
Debian Release: 4.0
APT prefers testing
APT policy: (900, 'testing'), (300, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18.20061123
Locale: LANG=en_AU, LC_CTYPE=en_AU (charmap=ISO-8859-1)
test_1009: test_1009.c Makefile
gcc -Wall -g -o test_1009 test_1009.c -lgd
clean:
rm test_1009
#include <gd.h>
#include <stdio.h>
int main()
{
gdImagePtr im = gdImageCreateTrueColor(10,10);
gdImageSetAntiAliased(im, gdTrueColorAlpha(255, 255, 255, 0));
gdImageLine(im,-1,-1,-1,-1,gdAntiAliased);
printf("OK\n");
return 0;
}
diff -ruN libgd2-2.0.33/gd.c.orig libgd2-2.0.33/gd.c
--- libgd2-2.0.33/gd.c.orig 2006-12-28 11:31:18.000000000 +0900
+++ libgd2-2.0.33/gd.c 2006-12-28 11:31:15.000000000 +0900
@@ -3102,7 +3102,10 @@
if (dx == 0 && dy == 0) {
/* TBB: allow setting points */
- gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
+ /* Watch out for -1's etc - possible with above expanded
+ * clipping bounds */
+ if (x1 >= 0 && y1 >= 0 && x1 < im->cx1 && y1 < im->cy1)
+ gdImageSetAAPixelColor(im, x1, y1, col, 0xFF);
return;
}
if (abs(dx) > abs(dy)) {