Browse Source

Validating the interface type in the virtual interface class.

Henrique Gottardi Werlang 1 year ago
parent
commit
af3397e42c
1 changed files with 12 additions and 7 deletions
  1. 12 7
      packages/rtl/src/rtti.pas

+ 12 - 7
packages/rtl/src/rtti.pas

@@ -2210,16 +2210,21 @@ begin
   InterfaceMaps := TJSObject.New;
   InterfaceMaps := TJSObject.New;
   FInterfaceType := FContext.GetType(PIID) as TRttiInterfaceType;
   FInterfaceType := FContext.GetType(PIID) as TRttiInterfaceType;
 
 
-  InterfaceInfo := FInterfaceType.InterfaceTypeInfo;
-
-  while Assigned(InterfaceInfo) do
+  if Assigned(FInterfaceType) then
   begin
   begin
-    InterfaceMaps[InterfaceInfo.InterfaceInfo.GUID] := GenerateNewMap(InterfaceInfo);
+    InterfaceInfo := FInterfaceType.InterfaceTypeInfo;
 
 
-    InterfaceInfo := InterfaceInfo.Ancestor;
-  end;
+    while Assigned(InterfaceInfo) do
+    begin
+      InterfaceMaps[InterfaceInfo.InterfaceInfo.GUID] := GenerateNewMap(InterfaceInfo);
 
 
-  JSThis['$intfmaps'] := InterfaceMaps;
+      InterfaceInfo := InterfaceInfo.Ancestor;
+    end;
+
+    JSThis['$intfmaps'] := InterfaceMaps;
+  end
+  else
+    raise EInvalidCast.Create;
 end;
 end;
 
 
 constructor TVirtualInterface.Create(PIID: PTypeInfo; const InvokeEvent: TVirtualInterfaceInvokeEvent);
 constructor TVirtualInterface.Create(PIID: PTypeInfo; const InvokeEvent: TVirtualInterfaceInvokeEvent);