Skip to content

Commit 9069a1a

Browse files
authored
Update Horse.ManipulateRequest.pas
Fixing Access Violation when Params=nil
1 parent c0a0f35 commit 9069a1a

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

src/Horse.ManipulateRequest.pas

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,21 @@ procedure Middleware(Req: THorseRequest; Res: THorseResponse; Next: TNextProc);
160160
after the process that de-serialize this info
161161
*)
162162
LRouteMatch := ExtractParamFromHorseRoute(Req.PathInfo);
163-
try
164-
if (LRouteMatch.Params.Count > 0) then
165-
begin
166-
for LKeySource in LRouteMatch.Params.Keys do
163+
if Assigned(LRouteMatch.Params) then
164+
begin
165+
try
166+
if (LRouteMatch.Params.Count > 0) then
167167
begin
168-
if LKeySource.Trim.IsEmpty then
169-
Continue;
170-
Req.Params.Dictionary.AddOrSetValue(LKeySource, LRouteMatch.Params.Items[LKeySource]);
168+
for LKeySource in LRouteMatch.Params.Keys do
169+
begin
170+
if LKeySource.Trim.IsEmpty then
171+
Continue;
172+
Req.Params.Dictionary.AddOrSetValue(LKeySource, LRouteMatch.Params.Items[LKeySource]);
173+
end;
171174
end;
175+
finally
176+
LRouteMatch.Params.Free;
172177
end;
173-
finally
174-
LRouteMatch.Params.Free;
175178
end;
176179
{$ENDIF}
177180
ManipulateRequestCallBack(Req);

0 commit comments

Comments
 (0)