TWriter.WriteProperty crashes on ancestor (persistent)
Original Reporter info from Mantis: Martin @martin_frb
-
Reporter name: Martin Friebe
Original Reporter info from Mantis: Martin @martin_frb
- Reporter name: Martin Friebe
Description:
please see the code snippet below, it is from
rtl\objpas\classes\writer.inc
procedure TWriter.WriteProperty(Instance: TPersistent; PropInfo: Pointer);
Bug #14364 shows a possibility where both AncestorObj and ObjValue are TPersitent.
This is: the object having the property is TComponent, but the property itself is TPersistent
Since they get casted to TComponent without being checked this leads to a crash.
Additional information:
tkClass:
begin
ObjValue := TObject(GetObjectProp(Instance, PropInfo));
if HasAncestor then
begin
AncestorObj := TObject(GetObjectProp(Ancestor, PropInfo));
if Assigned(AncestorObj) then
if Assigned(ObjValue) and
(TComponent(AncestorObj).Owner = FRootAncestor) and
(TComponent(ObjValue).Owner = Root) and
(UpperCase(TComponent(AncestorObj).Name) = UpperCase(TComponent(ObjValue).Name)) then
AncestorObj := ObjValue
// else
// AncestorObj := nil;
end else
AncestorObj := nil;
Mantis conversion info:
- Mantis ID: 14380
- Version: 2.3.1
- Fixed in version: 2.4.0
- Fixed in revision: 13733 (#580f9b64)
- Target version: 2.4.0