Commits

Fredrik Lundh committed 8b84b68

Fixed bug w. uninitialized image data when cropping outside the source image.

Comments (0)

Files changed (1)

libImaging/Crop.c

     Imaging imOut;
     int xsize, ysize;
     int dx0, dy0, dx1, dy1;
+    INT32 zero = 0;
     
     if (!imIn)
 	return (Imaging) ImagingError_ModeError();
 
     ImagingCopyInfo(imOut, imIn);
 
+    if (sx0 < 0 || sy0 < 0 || sx1 > imIn->xsize || sy1 > imIn->ysize)
+        ImagingFill(imOut, &zero);
+
     dx0 = -sx0;
     dy0 = -sy0;
     dx1 = imIn->xsize - sx0;