Sync to Wine-0_9_5:
authorGé van Geldorp <ge@gse.nl>
Fri, 6 Jan 2006 20:19:21 +0000 (20:19 +0000)
committerGé van Geldorp <ge@gse.nl>
Fri, 6 Jan 2006 20:19:21 +0000 (20:19 +0000)
Robert Shearman <rob@codeweavers.com>
- ole: Fix mis-handling of return value in StgStreamImpl_Read.
  BlockChainStream_ReadAt returns a BOOL, not an HRESULT so change
  StgStreamImpl_Read to handle this, by returning STG_E_READFAULT on
  failure.
- ole: Check the return value of IStream_SetSize in IStream_Read.
  Check the return value of IStream_SetSize in IStream_Read, since
  otherwise execution could continue on and cause heap corruption.

svn path=/trunk/; revision=20621

reactos/lib/ole32/hglobalstream.c
reactos/lib/ole32/stg_stream.c

index ca73a22..4d1d4b5 100644 (file)
@@ -313,7 +313,12 @@ static HRESULT WINAPI HGLOBALStreamImpl_Write(
   if (newSize.u.LowPart > This->streamSize.u.LowPart)
   {
     /* grow stream */
-   IStream_SetSize(iface, newSize);
+    HRESULT hr = IStream_SetSize(iface, newSize);
+    if (FAILED(hr))
+    {
+      ERR("IStream_SetSize failed with error 0x%08lx\n", hr);
+      return hr;
+    }
   }
 
   /*
index 40f0e81..19b8bda 100644 (file)
@@ -249,7 +249,7 @@ static HRESULT WINAPI StgStreamImpl_Read(
 
   ULONG bytesReadBuffer;
   ULONG bytesToReadFromBuffer;
-  HRESULT res = S_FALSE;
+  HRESULT res;
 
   TRACE("(%p, %p, %ld, %p)\n",
        iface, pv, cb, pcbRead);
@@ -282,11 +282,15 @@ static HRESULT WINAPI StgStreamImpl_Read(
   }
   else if (This->bigBlockChain!=0)
   {
-    res = BlockChainStream_ReadAt(This->bigBlockChain,
-                           This->currentPosition,
-                           bytesToReadFromBuffer,
-                           pv,
-                           pcbRead);
+    BOOL success = BlockChainStream_ReadAt(This->bigBlockChain,
+                                           This->currentPosition,
+                                           bytesToReadFromBuffer,
+                                           pv,
+                                           pcbRead);
+    if (success)
+      res = S_OK;
+    else
+      res = STG_E_READFAULT;
   }
   else
   {