Browse Source

* GetPropList returns nil if no items found. Memory Leak stopped in case of exception

git-svn-id: trunk@10580 -
michael 17 years ago
parent
commit
aaa394cb93
2 changed files with 11 additions and 7 deletions
  1. 8 6
      rtl/objpas/classes/writer.inc
  2. 3 1
      rtl/objpas/typinfo.pp

+ 8 - 6
rtl/objpas/classes/writer.inc

@@ -580,12 +580,14 @@ var PropCount,i : integer;
     PropList  : PPropList;
 begin
   PropCount:=GetPropList(Instance,PropList);
-  if PropCount>0 then begin
-    for i := 0 to PropCount-1 do
-      if IsStoredProp(Instance,PropList^[i]) then
-        WriteProperty(Instance,PropList^[i]);
-    Freemem(PropList);
-  end;
+  if PropCount>0 then 
+    try
+      for i := 0 to PropCount-1 do
+        if IsStoredProp(Instance,PropList^[i]) then
+          WriteProperty(Instance,PropList^[i]);
+    Finally    
+      Freemem(PropList);
+    end;
   Instance.DefineProperties(Self);
 end;
 

+ 3 - 1
rtl/objpas/typinfo.pp

@@ -743,7 +743,9 @@ begin
     begin
       getmem(PropList,result*sizeof(pointer));
       GetPropInfos(TypeInfo,PropList);
-    end;
+    end
+  else
+    PropList:=Nil;  
 end;