mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
fix for 0 sized images
This commit is contained in:
@@ -133,6 +133,11 @@ RLoadJPEG(RContext *context, char *file_name, int index)
|
||||
|
||||
jpeg_read_header(&cinfo, TRUE);
|
||||
|
||||
if (cinfo.image_width < 1 || cinfo.image_height < 1) {
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
goto bye;
|
||||
}
|
||||
|
||||
bptr = buffer[0] = (JSAMPROW)malloc(cinfo.image_width*cinfo.num_components);
|
||||
if (!buffer[0]) {
|
||||
RErrorCode = RERR_NOMEMORY;
|
||||
|
||||
@@ -86,7 +86,7 @@ RGetImageFromXPMData(RContext *context, char **data)
|
||||
int w, h, ccount, csize;
|
||||
|
||||
if (sscanf(data[line++], "%i %i %i %i", &w, &h, &ccount, &csize)!=4
|
||||
|| w <= 0 || h <= 0 || ccount <= 0 || csize <= 0)
|
||||
|| w <= 1 || h <= 1 || ccount <= 0 || csize <= 0)
|
||||
goto bad_format;
|
||||
|
||||
if (csize!=1 && csize!=2)
|
||||
|
||||
@@ -113,6 +113,15 @@ RLoadPNG(RContext *context, char *file, int index)
|
||||
&junk, &junk, &junk);
|
||||
|
||||
|
||||
/* sanity check */
|
||||
if (width < 1 || height < 1) {
|
||||
fclose(f);
|
||||
png_destroy_read_struct(&png, &pinfo, &einfo);
|
||||
RErrorCode = RERR_BADIMAGEFILE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* check for an alpha channel */
|
||||
if (png_get_valid(png, pinfo, PNG_INFO_tRNS))
|
||||
alpha = True;
|
||||
|
||||
@@ -154,7 +154,7 @@ RLoadPPM(RContext *context, char *file_name, int index)
|
||||
}
|
||||
|
||||
/* get size */
|
||||
if (sscanf(buffer, "%i %i", &w, &h)!=2)
|
||||
if (sscanf(buffer, "%i %i", &w, &h)!=2 || w < 1 || h < 1)
|
||||
goto bad_file;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user