--- a/src/Gimpmain.c
+++ b/src/Gimpmain.c
@@ -389,11 +389,11 @@
 
 	src.width = gimp_drawable->width;
 	src.height = gimp_drawable->height;
-	src.bitsPerPixel = (need_4bytes ? 32 : 24);
+	src.bitsPerPixel = 24;
 	src.bytesPerLine = src.width * src.bitsPerPixel / 8;
 	src.dataformat = _RGB;
 	src.dataSize = src.height * src.bytesPerLine;
-	src.data = (unsigned char **) mymalloc (src.dataSize);
+	src.data = (unsigned char **) mymalloc ((need_4bytes ? 4 : 3) * src.width * src.height);
 	src.selection.top = 0;
 	src.selection.left = 0;
 	src.selection.right = src.width;