Skip to content

Commit e9505ac

Browse files
committed
fix:
- Correção de memoryleak na conversão de StreamToString. #118 - Remoção de redundância do fix anterior. Fixed #118
1 parent 3cd74d9 commit e9505ac

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/base/RALParams.pas

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,7 @@ procedure TRALParam.SetAsStream(const AValue: TStream);
426426
AValue.Position := 0;
427427
FContent := TRALStringStream.Create(AValue);
428428
FContent.Position := 0;
429-
end
430-
else
431-
FContent := nil;
429+
end;
432430
end;
433431

434432
procedure TRALParam.SetAsString(const AValue: StringRAL);

src/utils/RALStream.pas

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface
1515

1616
TRALBinaryWriter = class
1717
private
18-
FStream : TStream;
18+
FStream: TStream;
1919
protected
2020
// read and write UTF-7
2121
function ReadSize: UInt64RAL;
@@ -158,7 +158,11 @@ function StreamToString(AStream: TStream): StringRAL;
158158
else
159159
begin
160160
vStream := TRALStringStream.Create(AStream);
161-
Result := TRALStringStream(vStream).DataString;
161+
try
162+
Result := TRALStringStream(vStream).DataString;
163+
finally
164+
FreeAndNil(vStream);
165+
end;
162166

163167
// vStream := TStringStream.Create(EmptyStr);
164168
// try

0 commit comments

Comments
 (0)