diff --git a/Source/BinInterop.cpp b/Source/BinInterop.cpp index d53b27be..0a3fb83e 100644 --- a/Source/BinInterop.cpp +++ b/Source/BinInterop.cpp @@ -455,7 +455,8 @@ DWORD GetDIBHeaderInfo(const void*pData, size_t DataSize, GENERICIMAGEINFO&Info) DWORD size = LE2HE32(p32[0]); if (size == 12) // BITMAPCOREHEADER { - Info.Width = LE2HE16(p16[2]), Info.Height = (INT32) (SHORT) LE2HE16(p16[3]); + Info.Width = LE2HE16(p16[2]), Info.RawHeight = (INT32) (SHORT) LE2HE16(p16[3]); + Info.Height = Info.RawHeight; // BITMAPCOREHEADER bitmaps cannot be top-down bitmaps (docs.microsoft.com/en-us/windows/win32/gdi/bitmap-header-types) Info.Planes = LE2HE16(p16[4]), Info.BPP = LE2HE16(p16[5]); return size; } diff --git a/Source/BinInterop.h b/Source/BinInterop.h index a65a8c35..bd0d9665 100644 --- a/Source/BinInterop.h +++ b/Source/BinInterop.h @@ -27,11 +27,12 @@ bool GetTLBVersion(const TCHAR *filepath, DWORD &high, DWORD &low); bool GetDLLVersion(const TCHAR *filepath, DWORD &high, DWORD &low); -typedef struct { +typedef struct GENERICIMAGEINFO { UINT32 Width, Height; INT32 RawHeight; WORD BPP, Planes; - bool IsTopDownBitmap() const { return Height != (UINT32) RawHeight; } + GENERICIMAGEINFO() : RawHeight(0) {} + bool IsTopDownBitmap() const { return Height != (UINT32) RawHeight && RawHeight; } } GENERICIMAGEINFO; DWORD GetDIBHeaderInfo(const void*pData, size_t DataSize, GENERICIMAGEINFO&Info); @@ -47,7 +48,7 @@ inline WORD IsICOCURFile(const void*pData) } inline WORD IsICOCURFile(const void*pData, size_t DataSize) { - return DataSize >= 6 ? IsICOCURFile(pData) : 0; + return DataSize > 6 ? IsICOCURFile(pData) : 0; } #endif //~ NSIS_BININTEROP_H