Vincent Povirk : ole32: Fix seeking backwards in hglobalstream.

Alexandre Julliard julliard at winehq.org
Thu May 27 10:46:40 CDT 2010


Module: wine
Branch: master
Commit: d64ee9ff11d8712bbb0c643f902a62a0ee557021
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d64ee9ff11d8712bbb0c643f902a62a0ee557021

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Wed May 26 12:15:11 2010 -0500

ole32: Fix seeking backwards in hglobalstream.

---

 dlls/ole32/hglobalstream.c       |   19 +++++++++++--------
 dlls/ole32/tests/hglobalstream.c |    4 ++--
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c
index 5742f99..ef616de 100644
--- a/dlls/ole32/hglobalstream.c
+++ b/dlls/ole32/hglobalstream.c
@@ -371,12 +371,6 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek(
   TRACE("(%p, %x%08x, %d, %p)\n", iface, dlibMove.u.HighPart,
 	dlibMove.u.LowPart, dwOrigin, plibNewPosition);
 
-  if (dlibMove.u.LowPart >= 0x80000000)
-  {
-    hr = STG_E_SEEKERROR;
-    goto end;
-  }
-
   /*
    * The file pointer is moved depending on the given "function"
    * parameter.
@@ -405,10 +399,19 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek(
   newPosition.u.HighPart = 0;
   newPosition.u.LowPart += dlibMove.QuadPart;
 
-end:
-  if (plibNewPosition) *plibNewPosition = newPosition;
+  if (dlibMove.u.LowPart >= 0x80000000 &&
+      newPosition.u.LowPart >= dlibMove.u.LowPart)
+  {
+    /* We tried to seek backwards and went past the start. */
+    hr = STG_E_SEEKERROR;
+    goto end;
+  }
+
   This->currentPosition = newPosition;
 
+end:
+  if (plibNewPosition) *plibNewPosition = This->currentPosition;
+
   return hr;
 }
 
diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c
index 6d2230d..0810d9f 100644
--- a/dlls/ole32/tests/hglobalstream.c
+++ b/dlls/ole32/tests/hglobalstream.c
@@ -177,8 +177,8 @@ static void test_streamonhglobal(IStream *pStream)
     ll.u.HighPart = 0;
     ll.u.LowPart = -sizeof(data);
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
-    todo_wine ok_ole_success(hr, "IStream_Seek");
-    todo_wine ok(ull.u.LowPart == 0, "LowPart set to %d\n", ull.u.LowPart);
+    ok_ole_success(hr, "IStream_Seek");
+    ok(ull.u.LowPart == 0, "LowPart set to %d\n", ull.u.LowPart);
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
     /* IStream_Seek -- invalid LowPart value (seek to start of stream-1) */




More information about the wine-cvs mailing list