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

Incorrect reading, potentially garbage in memory #47

Open
the-Arioch opened this issue Aug 29, 2022 · 0 comments
Open

Incorrect reading, potentially garbage in memory #47

the-Arioch opened this issue Aug 29, 2022 · 0 comments

Comments

@the-Arioch
Copy link
Contributor

zexmlss.pas(5907,19) Hint: Local variable "fcc" does not seem to be initialized

You confused TStream.Read and TStream.ReadBuffer!

procedure TZEPicture.AssignFromStream(AStream: TStream);
var
  fcc: LongWord;
begin
  if Assigned(FDataStream) then
    FreeAndNil(FDataStream);
  FFileName := '';
  FDataStream := TMemoryStream.Create();
  AStream.Position := 0;
  // detect file type
---  AStream.Read(fcc, SizeOf(fcc));
+++  AStream.ReadBuffer(fcc, SizeOf(fcc));
  if fcc = $474E5089 then
    FFileName := '.png'
  else if fcc = $E0FFD8FF then
    FFileName := '.jpeg';
  AStream.Position := 0;
  FDataStream.CopyFrom(AStream, AStream.Size);
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant