diff options
Diffstat (limited to 'converter/other/bmptopnm.c')
-rw-r--r-- | converter/other/bmptopnm.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c index 54868364..49e730fd 100644 --- a/converter/other/bmptopnm.c +++ b/converter/other/bmptopnm.c @@ -384,10 +384,17 @@ readWindowsBasic40ByteInfoHeader(FILE * const ifP, -----------------------------------------------------------------------------*/ int colorsused; /* ColorsUsed value from header */ unsigned short planesField, bitCountField; + int32_t colsField; - 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); |