Spelt / ZXing.Delphi

ZXing Barcode Scanning object Pascal Library for Delphi VCL and Delphi Firemonkey
Apache License 2.0
471 stars 206 forks source link

Memory Leak #84

Closed drum77 closed 5 years ago

drum77 commented 5 years ago

Memory Leak in ZXing.Datamatrix.Internal.Detector.pas line 374

l1 := (Abs((dimensionTop - transitionsBetween(topLeft, c1).Transitions)) + Abs((dimensionRight - transitionsBetween(bottomRight, c1).Transitions))); l2 := (Abs((dimensionTop - transitionsBetween(topLeft, c2).Transitions)) + Abs((dimensionRight - transitionsBetween(bottomRight, c2).Transitions)));

object TResultPointsAndTransitions not free

drum77 commented 5 years ago

Memory Leak in ZXing.Datamatrix.Internal.Decoder.pas line 163

// Error-correct and copy data blocks together into a stream of bytes
for j := 0 to Pred(dataBlocksCount) do
begin
  DataBlock := dataBlocks[j];
  codewordBytes := DataBlock.codewords;
  numDataCodewords := DataBlock.numDataCodewords;
  if (not correctErrors(codewordBytes, numDataCodewords)) then
  begin
    Result := nil;
    exit;
  end;
  for i := 0 to Pred(numDataCodewords) do
  begin
    // De-interlace data blocks.
    resultBytes[(i * dataBlocksCount) + j] := codewordBytes[i];
  end;

  DataBlock.Free;
end;

exit and dataBlocks not free

Spelt commented 5 years ago

Hi

Is this for all datamtrix codes? Can you otherwise add a barcode to the issue? A failing case?

Thanks!

Op 4 jul. 2019 om 11:48 heeft drum77 notifications@github.com het volgende geschreven:

Memory Leak in ZXing.Datamatrix.Internal.Decoder.pas line 163

// Error-correct and copy data blocks together into a stream of bytes for j := 0 to Pred(dataBlocksCount) do begin DataBlock := dataBlocks[j]; codewordBytes := DataBlock.codewords; numDataCodewords := DataBlock.numDataCodewords; if (not correctErrors(codewordBytes, numDataCodewords)) then begin Result := nil; exit; end; for i := 0 to Pred(numDataCodewords) do begin // De-interlace data blocks. resultBytes[(i * dataBlocksCount) + j] := codewordBytes[i]; end;

DataBlock.Free; end; exit and dataBlocks not free

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

matteopasini commented 5 years ago

Hi, I've had the same problem while reading a qrcode. I solved it by adding a free to DataBlock inside the function TDataMatrixDecoder.decode, and assigning the result of transitionsBetween() on line 374 of ZXing.Datamatrix.Internal.Detector.pas to a var and adding a free after the execution.

drum77 commented 5 years ago

thx

------------------ 原始邮件 ------------------ 发件人: "matteopasini"notifications@github.com; 发送时间: 2019年8月12日(星期一) 晚上6:55 收件人: "Spelt/ZXing.Delphi"ZXing.Delphi@noreply.github.com; 抄送: "楼屈屈"1816220978@qq.com;"Author"author@noreply.github.com; 主题: Re: [Spelt/ZXing.Delphi] Memory Leak (#84)

Hi, I've had the same problem while reading a qrcode. I solved it by adding a free to DataBlock inside the function TDataMatrixDecoder.decode, and assigning the result of transitionsBetween() on line 374 of ZXing.Datamatrix.Internal.Detector.pas to a var and adding a free after the execution.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.