Commit 8d9a7247 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

winmm: Fix SEEK_END handling for memory files.

parent 71b8a56c
...@@ -896,7 +896,7 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin) ...@@ -896,7 +896,7 @@ LONG WINAPI mmioSeek(HMMIO hmmio, LONG lOffset, INT iOrigin)
/* some memory mapped buffers are defined with -1 as a size */ /* some memory mapped buffers are defined with -1 as a size */
if ((wm->info.cchBuffer > 0) && if ((wm->info.cchBuffer > 0) &&
((offset < wm->info.lBufOffset) || ((offset < wm->info.lBufOffset) ||
(offset >= wm->info.lBufOffset + wm->info.cchBuffer) || (offset > wm->info.lBufOffset + wm->info.cchBuffer) ||
(offset > wm->dwFileSize && wm->info.fccIOProc != FOURCC_MEM) || (offset > wm->dwFileSize && wm->info.fccIOProc != FOURCC_MEM) ||
!wm->bBufferLoaded)) { !wm->bBufferLoaded)) {
......
...@@ -695,7 +695,16 @@ static void test_mmioSeek(void) ...@@ -695,7 +695,16 @@ static void test_mmioSeek(void)
if (hmmio != NULL) { if (hmmio != NULL) {
/* seek to the end */ /* seek to the end */
end = mmioSeek(hmmio, 0, SEEK_END); end = mmioSeek(hmmio, 0, SEEK_END);
todo_wine ok(end == size, "expected %d, got %d\n", size, end); ok(end == size, "expected %d, got %d\n", size, end);
/* test MMIOINFO values */
res = mmioGetInfo(hmmio, &mmio, 0);
ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
ok(mmio.pchNext == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchNext);
ok(mmio.pchEndRead == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndRead);
ok(mmio.pchEndWrite == mmio.pchBuffer + mmio.cchBuffer, "expected %p + %d, got %p\n", mmio.pchBuffer, mmio.cchBuffer, mmio.pchEndWrite);
ok(mmio.lBufOffset == 0, "expected %d, got %d\n", 0, mmio.lBufOffset);
ok(mmio.lDiskOffset == 0, "expected %d, got %d\n", 0, mmio.lDiskOffset);
/* seek backward from the end */ /* seek backward from the end */
pos = mmioSeek(hmmio, offset, SEEK_END); pos = mmioSeek(hmmio, offset, SEEK_END);
......
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