Commit 0de8d01b authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

winmm: Properly handle mmioRead/mmioWrite in case of errors.

In C, an inequality comparison between a signed and an unsigned integer ends up with an unsigned comparison. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52628Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com> Signed-off-by: 's avatarAndrew Eikum <aeikum@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 90ecf27d
......@@ -1234,7 +1234,7 @@ MMRESULT WINAPI mmioDescend(HMMIO hmmio, LPMMCKINFO lpck,
LONG ix;
ix = mmioRead(hmmio, (LPSTR)lpck, 3 * sizeof(DWORD));
if (ix < 2*sizeof(DWORD))
if (ix < 0 || ix < 2*sizeof(DWORD))
{
mmioSeek(hmmio, dwOldPos, SEEK_SET);
WARN("return ChunkNotFound\n");
......@@ -1336,7 +1336,7 @@ MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO* lpck, UINT uFlags)
ix = mmioWrite(hmmio, (LPSTR)lpck, size);
TRACE("after mmioWrite ix = %ld req = %ld, errno = %d\n", ix, size, errno);
if (ix < size) {
if (ix != size) {
mmioSeek(hmmio, dwOldPos, SEEK_SET);
WARN("return CannotWrite\n");
return MMIOERR_CANNOTWRITE;
......
......@@ -262,6 +262,7 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
INT count, bufsize, left, index;
struct playsound_data s;
void* data;
LONG r;
s.hEvent = 0;
......@@ -361,7 +362,8 @@ static DWORD WINAPI proc_PlaySound(LPVOID arg)
lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
if (!lpWaveFormat)
goto errCleanUp;
if (mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize) < sizeof(PCMWAVEFORMAT))
r = mmioRead(hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize);
if (r < 0 || r < sizeof(PCMWAVEFORMAT))
goto errCleanUp;
TRACE("wFormatTag=%04X !\n", lpWaveFormat->wFormatTag);
......
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