windowscodecs: Fix incorrect overflow check caused by test mistake.

This commit is contained in:
Alexandre Julliard 2009-09-25 15:57:41 +02:00
parent 33bfcdd044
commit 77c3997e90
2 changed files with 4 additions and 4 deletions

View File

@ -129,13 +129,12 @@ static HRESULT WINAPI StreamOnMemory_Seek(IStream *iface,
LARGE_INTEGER NewPosition; LARGE_INTEGER NewPosition;
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
if (dlibMove.QuadPart > 0xFFFFFFFF) return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
if (dwOrigin == STREAM_SEEK_SET) NewPosition.QuadPart = dlibMove.QuadPart; 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_CUR) NewPosition.QuadPart = This->dwCurPos + dlibMove.QuadPart;
else if (dwOrigin == STREAM_SEEK_END) NewPosition.QuadPart = This->dwMemsize + dlibMove.QuadPart; else if (dwOrigin == STREAM_SEEK_END) NewPosition.QuadPart = This->dwMemsize + dlibMove.QuadPart;
else return E_INVALIDARG; 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 > This->dwMemsize) return E_INVALIDARG;
if (NewPosition.QuadPart < 0) return E_INVALIDARG; if (NewPosition.QuadPart < 0) return E_INVALIDARG;
This->dwCurPos = NewPosition.u.LowPart; This->dwCurPos = NewPosition.u.LowPart;

View File

@ -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); 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 */ 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); 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 */ 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); IWICStream_Seek(pStream, LargeNull, STREAM_SEEK_SET, NULL);