Commit d64ee9ff authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

ole32: Fix seeking backwards in hglobalstream.

parent ff4292c2
......@@ -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;
}
......
......@@ -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) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment