Explorar o código

* fixed memory leak with the as operator, fixes #7174

git-svn-id: trunk@4355 -
florian %!s(int64=19) %!d(string=hai) anos
pai
achega
849878b472
Modificáronse 2 ficheiros con 6 adicións e 7 borrados
  1. 2 2
      rtl/inc/compproc.inc
  2. 4 5
      rtl/inc/objpas.inc

+ 2 - 2
rtl/inc/compproc.inc

@@ -251,8 +251,8 @@ function fpc_do_as(aclass : tclass;aobject : tobject): tobject; compilerproc;
 procedure fpc_intf_decr_ref(var i: pointer); compilerproc;
 procedure fpc_intf_incr_ref(i: pointer); compilerproc;
 procedure fpc_intf_assign(var D: pointer; const S: pointer); compilerproc;
-function  fpc_intf_as(const S: pointer; const iid: TGUID): pointer; compilerproc;
-function fpc_class_as_intf(const S: pointer; const iid: TGUID): pointer; compilerproc;
+function  fpc_intf_as(const S: pointer; const iid: TGUID): IInterface; compilerproc;
+function fpc_class_as_intf(const S: pointer; const iid: TGUID): IInterface; compilerproc;
 
 Function fpc_PushExceptAddr (Ft: Longint;_buf,_newaddr : pointer): PJmp_buf ; compilerproc;
 Procedure fpc_PushExceptObj (Obj : TObject; AnAddr,AFrame : Pointer); compilerproc;

+ 4 - 5
rtl/inc/objpas.inc

@@ -63,8 +63,7 @@
          D:=S;
       end;
 
-    function fpc_intf_as(const S: pointer; const iid: TGUID): pointer;[public,alias: 'FPC_INTF_AS']; compilerproc;
-
+    function fpc_intf_as(const S: pointer; const iid: TGUID): IInterface;[public,alias: 'FPC_INTF_AS']; compilerproc;
       var
         tmpi: pointer; // _AddRef before _Release
       begin
@@ -72,14 +71,14 @@
           begin
              if IUnknown(S).QueryInterface(iid,tmpi)<>S_OK then
                handleerror(219);
-             fpc_intf_as:=tmpi;
+             pointer(fpc_intf_as):=tmpi;
           end
         else
           fpc_intf_as:=nil;
       end;
 
 
-    function fpc_class_as_intf(const S: pointer; const iid: TGUID): pointer;[public,alias: 'FPC_CLASS_AS_INTF']; compilerproc;
+    function fpc_class_as_intf(const S: pointer; const iid: TGUID): IInterface;[public,alias: 'FPC_CLASS_AS_INTF']; compilerproc;
 
       var
         tmpi: pointer; // _AddRef before _Release
@@ -88,7 +87,7 @@
           begin
              if not TObject(S).GetInterface(iid,tmpi) then
                handleerror(219);
-             fpc_class_as_intf:=tmpi;
+             pointer(fpc_class_as_intf):=tmpi;
           end
         else
           fpc_class_as_intf:=nil;