Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed potential access violation in DrawPartialTrans #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions PNGImage.pas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{Portable Network Graphics Delphi 1.564 (31 July 2006) }
{Portable Network Graphics Delphi 1.565 (7 November 2023) }

{This is a full, open sourced implementation of png in Delphi }
{It has native support for most of png features including the }
Expand All @@ -9,6 +9,11 @@


{
Versino 1.565
2023-11-07 BUG 1 - There was a possible access violation
when applying the alpha mask because an extra
byte was read that possible fell beyond the
end of the row of pixels
Version 1.564
2006-07-25 BUG 1 - There was one GDI Palette object leak
when assigning from other PNG (fixed)
Expand Down Expand Up @@ -211,7 +216,7 @@ interface
zlibpas, pnglang;

const
LibraryVersion = '1.564';
LibraryVersion = '1.565';

{$IFNDEF UseDelphi}
const
Expand Down Expand Up @@ -4810,7 +4815,16 @@ procedure TPngObject.DrawPartialTrans(DC: HDC; Rect: TRect);
{Optmize when we don�t have transparency}
if (AlphaSource[i2] <> 0) then
if (AlphaSource[i2] = 255) then
ImageData[i] := pRGBQuad(@ImageSource[i2 * 3])^
begin
//20231107 Stijn Sanders
//ImageData[i] := pRGBQuad(@ImageSource[i2 * 3])^
//copied 4 bytes, but the 4th byte possibly falls outside of
//ImageSource on the last pixel, which may cause an access violation
ImageData[i].rgbRed := pRGBQuad(@ImageSource[i2 * 3]).rgbRed;
ImageData[i].rgbGreen := pRGBQuad(@ImageSource[i2 * 3]).rgbGreen;
ImageData[i].rgbBlue := pRGBQuad(@ImageSource[i2 * 3]).rgbBlue;
ImageData[i].rgbReserved := 0;
end
else
with ImageData[i] do
begin
Expand Down