tgatoimage(): avoid excessive memory allocation attempt, and fixes unaligned load...
[openjpeg.git] / src / bin / jp2 / convertbmp.c
index b49e7a080882ae59511e66bb0522122b3c266a4b..2715fdf2411cad1724928ced819d0e1159234f3b 100644 (file)
@@ -392,6 +392,10 @@ static OPJ_BOOL bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)
 
     header->biBitCount  = (OPJ_UINT16)getc(IN);
     header->biBitCount |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
+    if (header->biBitCount == 0) {
+        fprintf(stderr, "Error, invalid biBitCount %d\n", 0);
+        return OPJ_FALSE;
+    }
 
     if (header->biSize >= 40U) {
         header->biCompression  = (OPJ_UINT32)getc(IN);