Parcourir la source

[serializer] small fix

Exilon il y a 4 ans
Parent
commit
54e95b2de3
1 fichiers modifiés avec 2 ajouts et 1 suppressions
  1. 2 1
      Quick.Json.Serializer.pas

+ 2 - 1
Quick.Json.Serializer.pas

@@ -1188,6 +1188,7 @@ begin
     Exit;
     Exit;
   end;
   end;
 
 
+  Result := nil;
   try
   try
     //if is GenericList
     //if is GenericList
     if IsGenericList(aObject) then
     if IsGenericList(aObject) then
@@ -1263,7 +1264,7 @@ begin
   except
   except
     on E : Exception do
     on E : Exception do
     begin
     begin
-      Result.Free;
+      if Result <> nil then Result.Free;
       if not propertyname.IsEmpty then raise EJsonSerializeError.CreateFmt('Serialize Error -> Object property: "%s" (%s)',[propertyname,e.Message])
       if not propertyname.IsEmpty then raise EJsonSerializeError.CreateFmt('Serialize Error -> Object property: "%s" (%s)',[propertyname,e.Message])
        else raise EJsonSerializeError.CreateFmt('Serialize Error -> Object (%s)',[e.Message]);
        else raise EJsonSerializeError.CreateFmt('Serialize Error -> Object (%s)',[e.Message]);
     end;
     end;