about summary refs log tree commit diff
path: root/converter/other/bmptopnm.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/bmptopnm.c')
-rw-r--r--converter/other/bmptopnm.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c
index 88f8ccce..3d108bf7 100644
--- a/converter/other/bmptopnm.c
+++ b/converter/other/bmptopnm.c
@@ -372,10 +372,16 @@ readWindowsBasic40ByteInfoHeader(FILE *                 const ifP,
 -----------------------------------------------------------------------------*/
     int colorsimportant;   /* ColorsImportant value from header */
     int colorsused;        /* ColorsUsed value from header */
+    long colsField;
 
     headerP->class = C_WIN;
 
-    headerP->cols = GetLong(ifP);
+    colsField = GetLong(ifP);
+
+    if (colsField <= 0)
+        pm_error("Invalid BMP file: says width is %ld", colsField);
+
+    headerP->cols = (unsigned long)colsField;
     {
         long const cy = GetLong(ifP);
         if (cy == 0)