[PATCH v2] dmband: Handle the DirectX 7 version of DMUS_IO_INSTRUMENT structure.

Michael Stefaniuc mstefani at winehq.org
Fri Nov 8 15:32:56 CST 2019


From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
v2: Use offsetof()


 dlls/dmband/band.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/dmband/band.c b/dlls/dmband/band.c
index 4338791971..53f407c1a4 100644
--- a/dlls/dmband/band.c
+++ b/dlls/dmband/band.c
@@ -171,6 +171,8 @@ static const IDirectMusicObjectVtbl dmobject_vtbl = {
     band_IDirectMusicObject_ParseDescriptor
 };
 
+#define DMUS_IO_INSTRUMENT_DX7_SIZE offsetof(DMUS_IO_INSTRUMENT, nPitchBendRange)
+
 /* IDirectMusicBandImpl IPersistStream part: */
 static HRESULT parse_instrument(IDirectMusicBandImpl *This, DMUS_PRIVATE_CHUNK *pChunk,
         IStream *pStm)
@@ -199,8 +201,14 @@ static HRESULT parse_instrument(IDirectMusicBandImpl *This, DMUS_PRIVATE_CHUNK *
     switch (Chunk.fccID) { 
     case DMUS_FOURCC_INSTRUMENT_CHUNK: {
       TRACE_(dmfile)(": Instrument chunk\n");
-      if (Chunk.dwSize != sizeof(DMUS_IO_INSTRUMENT)) return E_FAIL;
-      IStream_Read (pStm, &inst, sizeof(DMUS_IO_INSTRUMENT), NULL);
+      if (Chunk.dwSize != sizeof(DMUS_IO_INSTRUMENT) && Chunk.dwSize != DMUS_IO_INSTRUMENT_DX7_SIZE) {
+        ERR_(dmfile)("unexpected size %d\n", Chunk.dwSize);
+        return E_FAIL;
+      }
+      IStream_Read (pStm, &inst, Chunk.dwSize, NULL);
+      if (Chunk.dwSize != sizeof(DMUS_IO_INSTRUMENT))
+        inst.nPitchBendRange = 0;
+
       TRACE_(dmfile)(" - dwPatch: %u\n", inst.dwPatch);
       TRACE_(dmfile)(" - dwAssignPatch: %u\n", inst.dwAssignPatch);
       TRACE_(dmfile)(" - dwNoteRanges[0]: %u\n", inst.dwNoteRanges[0]);
-- 
2.20.1




More information about the wine-devel mailing list