From 3d93de5edb92c06689815916d568c9e644a58753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salvador=20D=C3=ADaz=20Fau?= Date: Sat, 2 Nov 2024 17:55:43 +0100 Subject: [PATCH] Fixed memory leak in TCEFFileDialogInfo.ConvertExtensions --- source/uCEFFileDialogInfo.pas | 35 ++++++++++++++++++++--------------- update_CEF4Delphi.json | 2 +- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/source/uCEFFileDialogInfo.pas b/source/uCEFFileDialogInfo.pas index 31dfbc50..d31728f8 100644 --- a/source/uCEFFileDialogInfo.pas +++ b/source/uCEFFileDialogInfo.pas @@ -220,24 +220,29 @@ var TempSL : TStringList; TempExt : ustring; begin - for i := 1 to length(aExtensions) do - if (aExtensions[i] = ';') then aExtensions[i] := #13; + try + for i := 1 to length(aExtensions) do + if (aExtensions[i] = ';') then aExtensions[i] := #13; - TempSL := TStringList.Create; - TempSL.Text := aExtensions; - Result := ''; + TempSL := TStringList.Create; + TempSL.Text := aExtensions; + Result := ''; - i := 0; - while (i < TempSL.Count) do - begin - TempExt := TempSL[i]; - if (length(TempExt) > 1) and (TempExt[1] = '.') then - Result := Result + '*' + TempExt + ';'; - inc(i); - end; + i := 0; + while (i < TempSL.Count) do + begin + TempExt := TempSL[i]; + if (length(TempExt) > 1) and (TempExt[1] = '.') then + Result := Result + '*' + TempExt + ';'; + inc(i); + end; - if (length(Result) > 0) and (Result[length(Result)] = ';') then - Result := copy(Result, 1, pred(length(Result))); + if (length(Result) > 0) and (Result[length(Result)] = ';') then + Result := copy(Result, 1, pred(length(Result))); + finally + if assigned(TempSL) then + FreeAndNil(TempSL); + end; end; function TCEFFileDialogInfo.CEFAcceptFilterToDialogFilter(const aAcceptFilter, aExtension, aDescription : ustring) : ustring; diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 284bcf8c..dea27fb2 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 671, + "InternalVersion" : 672, "Name" : "cef4delphi_lazarus.lpk", "Version" : "130.1.10" }