[PATCH] dmstyle: check pNewMotif for NULL in the reader (Coverity)
Marcus Meissner
marcus at jet.franken.de
Wed Jan 6 14:20:16 CST 2010
Hi,
Coverity sees NULL pNewMotif and depending on the input
it can happen.
Ciao, Marcus
---
dlls/dmstyle/style.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/dlls/dmstyle/style.c b/dlls/dmstyle/style.c
index eb6e77c..c8424e0 100644
--- a/dlls/dmstyle/style.c
+++ b/dlls/dmstyle/style.c
@@ -745,6 +745,10 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSIST
break;
}
case DMUS_FOURCC_RHYTHM_CHUNK: {
+ if (!pNewMotif) {
+ ERR(": pNewMotif NULL\n");
+ return E_FAIL;
+ }
TRACE_(dmfile)(": Rhythm chunk\n");
IStream_Read (pStm, &pNewMotif->dwRhythm, sizeof(DWORD), NULL);
TRACE_(dmfile)(" - dwRhythm: %u\n", pNewMotif->dwRhythm);
@@ -754,6 +758,10 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSIST
break;
}
case DMUS_FOURCC_MOTIFSETTINGS_CHUNK: {
+ if (!pNewMotif) {
+ ERR(": pNewMotif NULL\n");
+ return E_FAIL;
+ }
TRACE_(dmfile)(": MotifSettings chunk (skipping for now)\n");
IStream_Read (pStm, &pNewMotif->settings, Chunk.dwSize, NULL);
/** TODO trace settings */
@@ -771,6 +779,10 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSIST
case DMUS_FOURCC_BAND_FORM: {
LPSTREAM pClonedStream = NULL;
+ if (!pNewMotif) {
+ ERR(": pNewMotif NULL\n");
+ return E_FAIL;
+ }
TRACE_(dmfile)(": BAND RIFF\n");
IStream_Clone (pStm, &pClonedStream);
@@ -807,6 +819,10 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSIST
break;
}
case FOURCC_LIST: {
+ if (!pNewMotif) {
+ ERR(": pNewMotif NULL\n");
+ return E_FAIL;
+ }
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
@@ -837,6 +853,10 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSIST
break;
}
case DMUS_FOURCC_PARTREF_LIST: {
+ if (!pNewMotif) {
+ ERR(": pNewMotif NULL\n");
+ return E_FAIL;
+ }
TRACE_(dmfile)(": PartRef list\n");
hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (iface, &Chunk, pStm, pNewMotif);
if (FAILED(hr)) return hr;
--
1.5.6
More information about the wine-patches
mailing list