diff --git a/dlls/windowscodecs/stream.c b/dlls/windowscodecs/stream.c index 5672ff50126..c59a9d27861 100644 --- a/dlls/windowscodecs/stream.c +++ b/dlls/windowscodecs/stream.c @@ -129,13 +129,12 @@ static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface, LARGE_INTEGER NewPosition; TRACE("(%p)\n", This); - if (dlibMove.QuadPart > 0xFFFFFFFF) return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - if (dwOrigin == STREAM_SEEK_SET) NewPosition.QuadPart = dlibMove.QuadPart; else if (dwOrigin == STREAM_SEEK_CUR) NewPosition.QuadPart = This->dwCurPos + dlibMove.QuadPart; else if (dwOrigin == STREAM_SEEK_END) NewPosition.QuadPart = This->dwMemsize + dlibMove.QuadPart; else return E_INVALIDARG; + if (NewPosition.u.HighPart) return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); if (NewPosition.QuadPart > This->dwMemsize) return E_INVALIDARG; if (NewPosition.QuadPart < 0) return E_INVALIDARG; This->dwCurPos = NewPosition.u.LowPart; diff --git a/dlls/windowscodecs/tests/stream.c b/dlls/windowscodecs/tests/stream.c index 197712e564a..6eff70a606f 100644 --- a/dlls/windowscodecs/tests/stream.c +++ b/dlls/windowscodecs/tests/stream.c @@ -107,9 +107,10 @@ static void test_StreamOnMemory(void) ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == sizeof(Memory) - 1, "bSeek cursor moved to position (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart); IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, &uNewPos); /* reset seek pointer */ - LargeInt.QuadPart = -sizeof(Memory) - 5; + LargeInt.QuadPart = -(LONGLONG)sizeof(Memory) - 5; hr = IWICStream_Seek(pStream, LargeInt, STREAM_SEEK_END, &uNewPos); - ok(hr == E_INVALIDARG, "Seek returned with %#x, expected %#x\n", hr, E_INVALIDARG); + ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), + "Seek returned with %#x, expected %#x\n", hr, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW)); ok(uNewPos.u.HighPart == 0 && uNewPos.u.LowPart == 0, "bSeek cursor moved to position (%u;%u), expected (%u;%u)\n", uNewPos.u.HighPart, uNewPos.u.LowPart, 0, 0); /* remains unchanged */ IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);