[WINESYNC][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=52628

Wine commit: 0de8d01b09b1cc7ca34f7ae3890b4a416ff801fe

author: Eric Pouech <eric.pouech@gmail.com>
Wed, 30 Mar 2022 12:57:44 +0000 (14:57 +0200)

committer: Alexandre Julliard <julliard@winehq.org>
Fri, 1 Apr 2022 20:59:40 +0000 (22:59 +0200)
This commit is contained in:
Thamatip Chitpong 2023-06-14 09:32:52 +07:00 committed by Stanislav Motylkov
parent e85c54a5c7
commit b30a8a0868
2 changed files with 6 additions and 4 deletions

View file

@ -1161,7 +1161,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");
@ -1263,7 +1263,7 @@ MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO* lpck, UINT uFlags)
ix = mmioWrite(hmmio, (LPSTR)lpck, size);
TRACE("after mmioWrite ix = %d req = %d, errno = %d\n", ix, size, errno);
if (ix < size) {
if (ix != size) {
mmioSeek(hmmio, dwOldPos, SEEK_SET);
WARN("return CannotWrite\n");
return MMIOERR_CANNOTWRITE;

View file

@ -428,6 +428,7 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
LPWAVEHDR waveHdr = NULL;
INT count, bufsize, left, index;
struct playsound_data s;
LONG r;
s.hEvent = 0;
@ -451,8 +452,9 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
if (!lpWaveFormat)
goto errCleanUp;
if (mmioRead(wps->hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize) < sizeof(PCMWAVEFORMAT))
goto errCleanUp;
r = mmioRead(wps->hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize);
if (r < 0 || r < sizeof(PCMWAVEFORMAT))
goto errCleanUp;
TRACE("wFormatTag=%04X !\n", lpWaveFormat->wFormatTag);
TRACE("nChannels=%d\n", lpWaveFormat->nChannels);