// sanity check for potential overflows if (INT_MAX/depth < width || bytes_per_line <= 0 || height <= 0 || INT_MAX/uint(bytes_per_line) < height || INT_MAX/sizeof(uchar *) < uint(height)) return 0;