Pārlūkot izejas kodu

* always decrease the refcount of the function result of helpers that return
interfaces (since that may not have been done yet in case of an optimized
assignment before r21955, and will never be done as of r21955)

git-svn-id: trunk@21962 -

Jonas Maebe 13 gadi atpakaļ
vecāks
revīzija
93c345a099
1 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 9 1
      rtl/inc/objpas.inc

+ 9 - 1
rtl/inc/objpas.inc

@@ -178,7 +178,11 @@
         tmpi2:=nil;
         tmpi2:=nil;
         if Assigned(S) and ((TObject(S).GetInterfaceWeak(IUnknown,tmpi2) and (IUnknown(tmpi2).QueryInterface(IID,tmpi)=S_OK)) or
         if Assigned(S) and ((TObject(S).GetInterfaceWeak(IUnknown,tmpi2) and (IUnknown(tmpi2).QueryInterface(IID,tmpi)=S_OK)) or
             TObject(S).GetInterface(IID,tmpi)) then
             TObject(S).GetInterface(IID,tmpi)) then
-          pointer(fpc_class_cast_intf):=tmpi
+          begin
+            // decrease reference count
+            fpc_class_cast_intf:=nil;
+            pointer(fpc_class_cast_intf):=tmpi
+          end
         else
         else
           fpc_class_cast_intf:=nil;
           fpc_class_cast_intf:=nil;
       end;
       end;
@@ -204,6 +208,8 @@
              tmpi:=nil;
              tmpi:=nil;
              if IUnknown(S).QueryInterface(iid,tmpi)<>S_OK then
              if IUnknown(S).QueryInterface(iid,tmpi)<>S_OK then
                handleerror(219);
                handleerror(219);
+             // decrease reference count
+             fpc_intf_as:=nil;
              pointer(fpc_intf_as):=tmpi;
              pointer(fpc_intf_as):=tmpi;
           end
           end
         else
         else
@@ -237,6 +243,8 @@
              tmpi2:=nil;
              tmpi2:=nil;
              if not ((TObject(S).GetInterfaceWeak(IUnknown,tmpi2) and (IUnknown(tmpi2).QueryInterface(IID,tmpi)=S_OK)) or TObject(S).GetInterface(IID,tmpi)) then
              if not ((TObject(S).GetInterfaceWeak(IUnknown,tmpi2) and (IUnknown(tmpi2).QueryInterface(IID,tmpi)=S_OK)) or TObject(S).GetInterface(IID,tmpi)) then
                handleerror(219);
                handleerror(219);
+             // decrease reference count
+             fpc_class_as_intf:=nil;
              pointer(fpc_class_as_intf):=tmpi;
              pointer(fpc_class_as_intf):=tmpi;
           end
           end
         else
         else