Robert Shearman : oleaut32: Fix differences between the size returned in sizing the

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 18 10:15:47 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 50a9c208c62d4f7e2538018825c74451a529bafa
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=50a9c208c62d4f7e2538018825c74451a529bafa

Author: Robert Shearman <rob at codeweavers.com>
Date:   Tue Apr 18 11:57:12 2006 +0100

oleaut32: Fix differences between the size returned in sizing the
buffer for interfaces and the buffer actually used.

---

 dlls/oleaut32/usrmarshal.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dlls/oleaut32/usrmarshal.c b/dlls/oleaut32/usrmarshal.c
index 4374348..4c765a2 100644
--- a/dlls/oleaut32/usrmarshal.c
+++ b/dlls/oleaut32/usrmarshal.c
@@ -287,14 +287,14 @@ static unsigned char* interface_variant_
 
   working_memlocked = GlobalLock(working_mem);
   memcpy(Buffer, &size, sizeof(ULONG)); /* copy the buffersize */
-  Buffer += sizeof(ULONG);
-  memcpy(Buffer, working_memlocked, size);
+  memcpy(Buffer + sizeof(ULONG), working_memlocked, size);
   GlobalUnlock(working_mem);
 
   IStream_Release(working);
 
-  TRACE("done, size=%ld\n", sizeof(ULONG) + size);
-  return Buffer + sizeof(ULONG) + size;
+  /* size includes the ULONG for the size written above */
+  TRACE("done, size=%ld\n", size);
+  return Buffer + size;
 }
 
 /* helper: called for VT_DISPATCH / VT_UNKNOWN variants to unmarshal the buffer. returns Buffer on failure, new position otherwise */
@@ -314,8 +314,7 @@ static unsigned char *interface_variant_
   /* get the buffersize */
   memcpy(&size, Buffer, sizeof(ULONG));
   TRACE("buffersize=%ld\n", size);
-  Buffer += sizeof(ULONG);
-  
+
   working_mem = GlobalAlloc(0, size);
   if (!working_mem) return oldpos;
 
@@ -328,7 +327,7 @@ static unsigned char *interface_variant_
   working_memlocked = GlobalLock(working_mem);
   
   /* now we copy the contents of the marshalling buffer to working_memlocked, unlock it, and demarshal the stream */
-  memcpy(working_memlocked, Buffer, size);
+  memcpy(working_memlocked, Buffer + sizeof(ULONG), size);
   GlobalUnlock(working_mem);
 
   hr = CoUnmarshalInterface(working, riid, (void**)&V_UNKNOWN(pvar));
@@ -339,8 +338,9 @@ static unsigned char *interface_variant_
 
   IStream_Release(working); /* this also frees the underlying hglobal */
 
-  TRACE("done, processed=%ld bytes\n", sizeof(ULONG) + size);
-  return Buffer + sizeof(ULONG) + size;
+  /* size includes the ULONG for the size written above */
+  TRACE("done, processed=%ld bytes\n", size);
+  return Buffer + size;
 }
 
 




More information about the wine-cvs mailing list