Commit 110cca72 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

Add some checks and fix some stream leaks.

parent 65581b84
...@@ -194,15 +194,15 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject (LPDIRECTMUSI ...@@ -194,15 +194,15 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject (LPDIRECTMUSI
/* create stream and associate it with file */ /* create stream and associate it with file */
result = DMUSIC_CreateDirectMusicLoaderFileStream ((LPVOID*)&pStream); result = DMUSIC_CreateDirectMusicLoaderFileStream ((LPVOID*)&pStream);
if (FAILED(result)) { if (FAILED(result)) {
ERR(": could not create loader stream\n"); ERR(": could not create file stream\n");
return result; return result;
} }
result = IDirectMusicLoaderFileStream_Attach (pStream, wszFileName, iface); result = IDirectMusicLoaderFileStream_Attach (pStream, wszFileName, iface);
if (FAILED(result)) { if (FAILED(result)) {
ERR(": could not attach stream to file\n"); ERR(": could not attach stream to file\n");
IStream_Release (pStream);
return result; return result;
} }
} }
else if (pDesc->dwValidData & DMUS_OBJ_MEMORY) { else if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
/* load object from resource */ /* load object from resource */
...@@ -216,6 +216,7 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject (LPDIRECTMUSI ...@@ -216,6 +216,7 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject (LPDIRECTMUSI
result = IDirectMusicLoaderResourceStream_Attach (pStream, pDesc->pbMemData, pDesc->llMemLength, 0, iface); result = IDirectMusicLoaderResourceStream_Attach (pStream, pDesc->pbMemData, pDesc->llMemLength, 0, iface);
if (FAILED(result)) { if (FAILED(result)) {
ERR(": could not attach stream to resource\n"); ERR(": could not attach stream to resource\n");
IStream_Release (pStream);
return result; return result;
} }
} }
...@@ -231,6 +232,7 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject (LPDIRECTMUSI ...@@ -231,6 +232,7 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_GetObject (LPDIRECTMUSI
result = IDirectMusicLoaderGenericStream_Attach (pStream, pDesc->pStream, iface); result = IDirectMusicLoaderGenericStream_Attach (pStream, pDesc->pStream, iface);
if (FAILED(result)) { if (FAILED(result)) {
ERR(": failed to attach stream\n"); ERR(": failed to attach stream\n");
IStream_Release (pStream);
return result; return result;
} }
} else { } else {
...@@ -323,6 +325,7 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_SetObject (LPDIRECTMUSI ...@@ -323,6 +325,7 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_SetObject (LPDIRECTMUSI
DMUS_OBJECTDESC Desc; DMUS_OBJECTDESC Desc;
struct list *pEntry; struct list *pEntry;
LPWINE_LOADER_ENTRY pObjectEntry, pNewEntry; LPWINE_LOADER_ENTRY pObjectEntry, pNewEntry;
HRESULT hr;
TRACE("(%p, %p): pDesc:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC(pDesc)); TRACE("(%p, %p): pDesc:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC(pDesc));
...@@ -344,21 +347,48 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_SetObject (LPDIRECTMUSI ...@@ -344,21 +347,48 @@ HRESULT WINAPI IDirectMusicLoaderImpl_IDirectMusicLoader_SetObject (LPDIRECTMUSI
strcpyW(p, pDesc->wszFileName); strcpyW(p, pDesc->wszFileName);
} }
/* create stream */ /* create stream */
DMUSIC_CreateDirectMusicLoaderFileStream ((LPVOID*)&pStream); hr = DMUSIC_CreateDirectMusicLoaderFileStream ((LPVOID*)&pStream);
if (FAILED(hr)) {
ERR(": could not create file stream\n");
return DMUS_E_LOADER_FAILEDOPEN;
}
/* attach stream */ /* attach stream */
IDirectMusicLoaderFileStream_Attach (pStream, wszFileName, iface); hr = IDirectMusicLoaderFileStream_Attach (pStream, wszFileName, iface);
if (FAILED(hr)) {
ERR(": could not attach stream to file\n");
IStream_Release (pStream);
return DMUS_E_LOADER_FAILEDOPEN;
}
} }
else if (pDesc->dwValidData & DMUS_OBJ_STREAM) { else if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
/* create stream */ /* create stream */
DMUSIC_CreateDirectMusicLoaderGenericStream ((LPVOID*)&pStream); hr = DMUSIC_CreateDirectMusicLoaderGenericStream ((LPVOID*)&pStream);
if (FAILED(hr)) {
ERR(": could not create generic stream\n");
return DMUS_E_LOADER_FAILEDOPEN;
}
/* attach stream */ /* attach stream */
IDirectMusicLoaderGenericStream_Attach (pStream, pDesc->pStream, iface); hr = IDirectMusicLoaderGenericStream_Attach (pStream, pDesc->pStream, iface);
if (FAILED(hr)) {
ERR(": could not attach stream\n");
IStream_Release (pStream);
return DMUS_E_LOADER_FAILEDOPEN;
}
} }
else if (pDesc->dwValidData & DMUS_OBJ_MEMORY) { else if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
/* create stream */ /* create stream */
DMUSIC_CreateDirectMusicLoaderResourceStream ((LPVOID*)&pStream); hr = DMUSIC_CreateDirectMusicLoaderResourceStream ((LPVOID*)&pStream);
if (FAILED(hr)) {
ERR(": could not create resource stream\n");
return DMUS_E_LOADER_FAILEDOPEN;
}
/* attach stream */ /* attach stream */
IDirectMusicLoaderResourceStream_Attach (pStream, pDesc->pbMemData, pDesc->llMemLength, 0, iface); hr = IDirectMusicLoaderResourceStream_Attach (pStream, pDesc->pbMemData, pDesc->llMemLength, 0, iface);
if (FAILED(hr)) {
ERR(": could not attach stream to resource\n");
IStream_Release (pStream);
return DMUS_E_LOADER_FAILEDOPEN;
}
} }
else { else {
ERR(": no way to get additional info\n"); ERR(": no way to get additional info\n");
......
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