Fixed buffer overflow when saving certain images in the Windows icon format.
When an image did not have a width with a multiple of 4 the calculations for the number of padding bytes (to get a scan line DWORD aligned) would be wrong. This caused a buffer overrun when saving the 1 bits per pixel mask. Fixes #12937. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -146,8 +146,8 @@ bool wxBMPHandler::SaveDib(wxImage *image,
|
||||
}
|
||||
|
||||
unsigned width = image->GetWidth();
|
||||
unsigned row_padding = (4 - int(width*bpp/8.0) % 4) % 4; // # bytes to pad to dword
|
||||
unsigned row_width = int(width * bpp/8.0) + row_padding; // # of bytes per row
|
||||
unsigned row_padding = (4 - ((width * bpp + 7) / 8) % 4) % 4; // # bytes to pad to dword
|
||||
unsigned row_width = (width * bpp + 7) / 8 + row_padding; // # of bytes per row
|
||||
|
||||
struct
|
||||
{
|
||||
|
Reference in New Issue
Block a user