wine/dlls/oleaut32 tmarshal.c

Alexandre Julliard julliard at wine.codeweavers.com
Wed Nov 2 14:00:00 CST 2005


ChangeSet ID:	21055
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/02 14:00:00

Modified files:
	dlls/oleaut32  : tmarshal.c 

Log message:
	Robert Shearman <rob at codeweavers.com>
	- Make sure to clean up properly on error.
	- Restrict the critical section to getting the channel buffer and
	adding a reference to it.

Patch: http://cvs.winehq.org/patch.py?id=21055

Old revision  New revision  Changes     Path
 1.70          1.71          +17 -13     wine/dlls/oleaut32/tmarshal.c

Index: wine/dlls/oleaut32/tmarshal.c
diff -u -p wine/dlls/oleaut32/tmarshal.c:1.70 wine/dlls/oleaut32/tmarshal.c:1.71
--- wine/dlls/oleaut32/tmarshal.c:1.70	2 Nov 2005 20: 0: 0 -0000
+++ wine/dlls/oleaut32/tmarshal.c	2 Nov 2005 20: 0: 0 -0000
@@ -1155,15 +1155,16 @@ xCall(LPVOID retptr, int method, TMProxy
     UINT		nrofnames;
     DWORD		remoteresult = 0;
     ITypeInfo 		*tinfo;
+    IRpcChannelBuffer *chanbuf;
 
     EnterCriticalSection(&tpinfo->crit);
 
     hres = _get_funcdesc(tpinfo->tinfo,method,&tinfo,&fdesc,&iname,&fname);
     if (hres) {
-	ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method);
+        ERR("Did not find typeinfo/funcdesc entry for method %d!\n",method);
         ITypeInfo_Release(tinfo);
         LeaveCriticalSection(&tpinfo->crit);
-	return E_FAIL;
+        return E_FAIL;
     }
 
     if (!tpinfo->chanbuf)
@@ -1173,6 +1174,10 @@ xCall(LPVOID retptr, int method, TMProxy
         LeaveCriticalSection(&tpinfo->crit);
         return RPC_E_DISCONNECTED;
     }
+    chanbuf = tpinfo->chanbuf;
+    IRpcChannelBuffer_AddRef(chanbuf);
+
+    LeaveCriticalSection(&tpinfo->crit);
 
     if (relaydeb) {
        TRACE_(olerelay)("->");
@@ -1234,19 +1239,17 @@ xCall(LPVOID retptr, int method, TMProxy
     memset(&msg,0,sizeof(msg));
     msg.cbBuffer = buf.curoff;
     msg.iMethod  = method;
-    hres = IRpcChannelBuffer_GetBuffer(tpinfo->chanbuf,&msg,&(tpinfo->iid));
+    hres = IRpcChannelBuffer_GetBuffer(chanbuf,&msg,&(tpinfo->iid));
     if (hres) {
 	ERR("RpcChannelBuffer GetBuffer failed, %lx\n",hres);
-        LeaveCriticalSection(&tpinfo->crit);
-	return hres;
+	goto exit;
     }
     memcpy(msg.Buffer,buf.base,buf.curoff);
     if (relaydeb) TRACE_(olerelay)("\n");
-    hres = IRpcChannelBuffer_SendReceive(tpinfo->chanbuf,&msg,&status);
+    hres = IRpcChannelBuffer_SendReceive(chanbuf,&msg,&status);
     if (hres) {
 	ERR("RpcChannelBuffer SendReceive failed, %lx\n",hres);
-        LeaveCriticalSection(&tpinfo->crit);
-	return hres;
+	goto exit;
     }
 
     if (relaydeb) TRACE_(olerelay)(" status = %08lx (",status);
@@ -1293,16 +1296,17 @@ xCall(LPVOID retptr, int method, TMProxy
 
     hres = xbuf_get(&buf, (LPBYTE)&remoteresult, sizeof(DWORD));
     if (hres != S_OK)
-	return hres;
+        goto exit;
     if (relaydeb) TRACE_(olerelay)(") = %08lx\n", remoteresult);
 
-    if (status != S_OK) /* OLE/COM internal error */
-	return status;
+    hres = remoteresult;
 
+exit:
     HeapFree(GetProcessHeap(),0,buf.base);
+    IRpcChannelBuffer_Release(chanbuf);
     ITypeInfo_Release(tinfo);
-    LeaveCriticalSection(&tpinfo->crit);
-    return remoteresult;
+    TRACE("-- 0x%08lx\n", hres);
+    return hres;
 }
 
 HRESULT WINAPI ProxyIUnknown_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)



More information about the wine-cvs mailing list