+ i_push_errorf(0, "Channels must be positive and <= %d", MAXCHANNELS);
+ return NULL;
+ }
+ bytes = sizeof(i_palidx) * x * y;
+ if (bytes / y / sizeof(i_palidx) != x) {
+ i_push_error(0, "integer overflow calculating image allocation");
+ return NULL;
+ }
+
+ /* basic assumption: we can always allocate a buffer representing a
+ line from the image, otherwise we're going to have trouble
+ working with the image */
+ line_bytes = sizeof(i_color) * x;
+ if (line_bytes / x != sizeof(i_color)) {
+ i_push_error(0, "integer overflow calculating scanline allocation");