From 490754b30f7d56043bead2def01e7241d3654dc0 Mon Sep 17 00:00:00 2001 From: Augusto Fraga Giachero Date: Sat, 2 Jun 2018 14:16:04 -0300 Subject: [PATCH] Fix bad_alloc exception when loading bmp images with negative height (#1341) The 'long' type can be 32 bits or 64 bits depending on what compiler you are using (LLP64 vs LP64). If the long type is 64 bits the biHeight variable will receive a very big number when the bmp image height is negative, causing a std::bad_alloc exception when calling the 'image.set_size' method. --- dlib/image_loader/image_loader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlib/image_loader/image_loader.h b/dlib/image_loader/image_loader.h index a5083dd47..8319f7387 100644 --- a/dlib/image_loader/image_loader.h +++ b/dlib/image_loader/image_loader.h @@ -44,7 +44,7 @@ namespace dlib unsigned long bfReserved; unsigned long biSize; unsigned long biWidth; - long biHeight; + int32 biHeight; unsigned short biBitCount; unsigned long biCompression; /*