Commits

pajoye  committed 4770e2b

- add sanity checks for alloc error in gdImageFill

  • Participants
  • Parent commits f462306

Comments (0)

Files changed (1)

 	srcx = x % gdImageSX(im->tile);
 	srcy = y % gdImageSY(im->tile);
 	p = gdImageGetPixel(im->tile, srcx, srcy);
-
-	if (im->trueColor) {
+	if (p == im->tile->transparent) {
+		tileColor = im->transparent;
+	} else if (im->trueColor) {
 		if (im->tile->trueColor) {
 			tileColor = p;
 		} else {
 	struct seg *stack;
 	struct seg *sp;
 
-	if (!im->trueColor && nc > im->colorsTotal) {
+	if (!im->trueColor && nc > (im->colorsTotal - 1)) {
 		return;
 	}
 
 	}
 
 	stack = (struct seg *)gdMalloc(sizeof(struct seg) * ((int)(im->sy*im->sx)/4));
+	if (!stack) {
+		return;
+	}
 	sp = stack;
 
 	/* required! */
 	}
 
 	stack = (struct seg *)gdMalloc(sizeof(struct seg) * ((int)(im->sy*im->sx)/4));
+	if (!stack) {
+		return;
+	}
 	sp = stack;
 
 	oc = gdImageGetPixel(im, x, y);