dmband: Avoid cloning stream in parse_bands_list.

A stream that doesn't implement ::Clone can be passed, causing IStream_Seek to crash.

Signed-off-by: Myah Caron <qsniyg@protonmail.com>
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Myah Caron 2020-09-17 05:18:08 -07:00 committed by Alexandre Julliard
parent d28c7938c7
commit 2cf69bb5a5
1 changed files with 10 additions and 9 deletions

View File

@ -425,21 +425,22 @@ static HRESULT parse_bands_list(IDirectMusicBandTrack *This, DMUS_PRIVATE_CHUNK
StreamSize = Chunk.dwSize - sizeof(FOURCC); StreamSize = Chunk.dwSize - sizeof(FOURCC);
switch (Chunk.fccID) { switch (Chunk.fccID) {
case DMUS_FOURCC_BAND_FORM: { case DMUS_FOURCC_BAND_FORM: {
LPSTREAM pClonedStream = NULL; ULARGE_INTEGER liOrigPos;
TRACE_(dmfile)(": BAND RIFF\n"); TRACE_(dmfile)(": BAND RIFF\n");
IStream_Clone (pStm, &pClonedStream);
liMove.QuadPart = 0; liMove.QuadPart = 0;
liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD)); IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, &liOrigPos);
IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
hr = load_band(This, pClonedStream, &pBand, &header); liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
hr = load_band(This, pStm, &pBand, &header);
if (FAILED(hr)) { if (FAILED(hr)) {
ERR(": could not load track\n"); ERR(": could not load track\n");
return hr; return hr;
} }
IStream_Release (pClonedStream); liMove.QuadPart = (LONGLONG)liOrigPos.QuadPart;
IStream_Seek (pStm, liMove, STREAM_SEEK_SET, NULL);
IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */ IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */