Skip to content

Commit

Permalink
Fixed a potential memory leak in AddProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
paolo-rossi committed May 4, 2024
1 parent 731c397 commit 02c7fbe
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/OpenAPI.Model.Schema.pas
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,11 @@ function TOpenAPISchema.AddEnum(const AValue: TValue): TOpenAPIAny;

function TOpenAPISchema.AddProperty(const AKeyName: string): TOpenAPISchema;
begin
Result := TOpenAPISchema.Create;

FProperties.Add(AKeyName, Result);
if not FProperties.TryGetValue(AKeyName, Result) then
begin
Result := TOpenAPISchema.Create;
FProperties.Add(AKeyName, Result);
end;
end;

constructor TOpenAPISchema.Create;
Expand Down

0 comments on commit 02c7fbe

Please sign in to comment.