diff options
Diffstat (limited to 'converter/other/bmptopnm.c')
-rw-r--r-- | converter/other/bmptopnm.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c index bb49f4a4..05749c27 100644 --- a/converter/other/bmptopnm.c +++ b/converter/other/bmptopnm.c @@ -369,12 +369,18 @@ readWindowsBasic40ByteInfoHeader(FILE * const ifP, int colorsimportant; /* ColorsImportant value from header */ int colorsused; /* ColorsUsed value from header */ unsigned short planesField, bitCountField; + int32_t colsField; headerP->class = C_WIN; - headerP->cols = GetLong(ifP); - if (headerP->cols == 0) + pm_readlittlelong2(ifP, &colsField); + + if (colsField == 0) pm_error("Invalid BMP file: says width is zero"); + else if (colsField < 0) + pm_error("Invalid BMP file: says width is negative (%d)", colsField); + else + headerP->cols = (unsigned int)colsField; { long const cy = GetLong(ifP); |