IndySockets / Indy

Indy - Internet Direct
https://www.indyproject.org
451 stars 153 forks source link

GPF in IdASN1Coder #502

Closed sstewart1967 closed 1 year ago

sstewart1967 commented 1 year ago

There is an issue in the IdASN1Coder unit. In this method:

procedure TIdASN1Encoder.StartSequence(aClass: TIdASN1IdentifierClass; iTag: Integer);

the newly created sequence is added to the internal list but the free'd immediately which gives a bad pointer reference.

This is the code:

procedure TIdASN1Encoder.StartSequence(aClass: TIdASN1IdentifierClass; iTag: Integer);
var
  oSequence : TIdASN1Sequence;
begin
  oSequence := TIdASN1Sequence.create;
  try
    oSequence.IdClass := aClass;
    oSequence.Tag := iTag;
    oSequence.Contents := '';
    FSequences.add(oSequence);
  finally
    **//oSequence.Free;     I commented out this line and everything works for me.**
  end;
end;