[PATCH] ole32: Fixed 2 uninitialized variable use (Coverity)

Marcus Meissner marcus at jet.franken.de
Sat May 8 16:50:18 CDT 2010


hr is used uninitialized under some loop conditions
(possibly never met).

byteswritten is used even with failed hr from the write
code.... Handle this differently.

Ciao, Marcus
---
 dlls/ole32/storage32.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index bc1fb96..6c3e507 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -4096,9 +4096,10 @@ static HRESULT StorageBaseImpl_CopyStream(
       if (SUCCEEDED(hr))
         hr = StorageBaseImpl_StreamWriteAt(dst, dst_entry, bytes_copied, bytestocopy,
           data, &byteswritten);
-      if (SUCCEEDED(hr) && byteswritten != bytestocopy) hr = STG_E_WRITEFAULT;
-
-      bytes_copied.QuadPart += byteswritten;
+      if (SUCCEEDED(hr)) {
+        if (byteswritten != bytestocopy) hr = STG_E_WRITEFAULT;
+        bytes_copied.QuadPart += byteswritten;
+      }
     }
   }
 
@@ -4370,7 +4371,7 @@ static HRESULT TransactedSnapshotImpl_CopyTree(TransactedSnapshotImpl* This)
 {
   DirRef cursor;
   TransactedDirEntry *entry;
-  HRESULT hr;
+  HRESULT hr = S_OK;
 
   cursor = This->base.storageDirEntry;
   entry = &This->entries[cursor];
-- 
1.5.6



More information about the wine-patches mailing list