ole32: Fix seeking backwards in hglobalstream.

oldstable
Vincent Povirk 2010-05-26 12:15:11 -05:00 committed by Alexandre Julliard
parent ff4292c229
commit d64ee9ff11
2 changed files with 13 additions and 10 deletions

View File

@ -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;
}

View File

@ -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) */