Skip to content

Commit

Permalink
Merge pull request #133 from mateusvicente100/master
Browse files Browse the repository at this point in the history
Bug Variant or safe array index out of bounds
  • Loading branch information
viniciussanchez committed Feb 14, 2022
2 parents 58316ec + a1f375e commit 6f07f2f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/DataSet.Serialize.Import.pas
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ procedure TJSONSerialize.JSONObjectToDataSet(const AJSONObject: TJSONObject; con
{$ENDIF}
LObjectState: string;
LFormatSettings: TFormatSettings;
LKeyValues: TKeyValues;
LTryStrToDateTime: TDateTime
begin
if (not Assigned(AJSONObject)) or (not Assigned(ADataSet)) or (AJSONObject.Count = 0) then
Expand Down Expand Up @@ -264,8 +265,12 @@ procedure TJSONSerialize.JSONObjectToDataSet(const AJSONObject: TJSONObject; con
TFDDataSet(ADataSet).MasterSource := nil;
end;
{$ENDIF}
if not ADataSet.Locate(GetKeyFieldsDataSet(ADataSet), VarArrayOf(GetKeyValuesDataSet(ADataSet, AJSONObject)), []) then
Exit;
LKeyValues := GetKeyValuesDataSet(ADataSet, AJSONObject);
if (Length(LKeyValues) = 0) or (not ADataSet.Locate(GetKeyFieldsDataSet(ADataSet), VarArrayOf(LKeyValues), [])) then
begin
if ADataSet.State <> dsInsert then
ADataSet.Append;
end;
if TUpdateStatus.usModified.ToString = LObjectState then
begin
if ADataSet.State <> dsEdit then
Expand Down

0 comments on commit 6f07f2f

Please sign in to comment.