ole32: Fix seeking backwards in hglobalstream.
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 @@
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 @@
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 @@
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) */