[DMLOADER] Add some checks and fix some stream leaks
Christian Costa
titan.costa at wanadoo.fr
Mon Nov 7 17:19:35 CST 2005
Hi,
Changelog:
Add some checks and fix some stream leaks.
Christian Costa titan.costa at wanadoo.fr
-------------- next part --------------
Index: dlls/dmloader/loader.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/loader.c,v
retrieving revision 1.20
diff -u -r1.20 loader.c
--- dlls/dmloader/loader.c 26 Jul 2005 18:32:54 -0000 1.20
+++ dlls/dmloader/loader.c 7 Nov 2005 22:08:50 -0000
@@ -194,15 +194,15 @@
/* create stream and associate it with file */
result = DMUSIC_CreateDirectMusicLoaderFileStream ((LPVOID*)&pStream);
if (FAILED(result)) {
- ERR(": could not create loader stream\n");
+ ERR(": could not create file stream\n");
return result;
}
result = IDirectMusicLoaderFileStream_Attach (pStream, wszFileName, iface);
if (FAILED(result)) {
- ERR(": could not attach stream to file\n");
+ ERR(": could not attach stream to file\n");
+ IStream_Release (pStream);
return result;
}
-
}
else if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
/* load object from resource */
@@ -215,7 +215,8 @@
}
result = IDirectMusicLoaderResourceStream_Attach (pStream, pDesc->pbMemData, pDesc->llMemLength, 0, iface);
if (FAILED(result)) {
- ERR(": could not attach stream to resource\n");
+ ERR(": could not attach stream to resource\n");
+ IStream_Release (pStream);
return result;
}
}
@@ -231,6 +232,7 @@
result = IDirectMusicLoaderGenericStream_Attach (pStream, pDesc->pStream, iface);
if (FAILED(result)) {
ERR(": failed to attach stream\n");
+ IStream_Release (pStream);
return result;
}
} else {
@@ -323,6 +325,7 @@
DMUS_OBJECTDESC Desc;
struct list *pEntry;
LPWINE_LOADER_ENTRY pObjectEntry, pNewEntry;
+ HRESULT hr;
TRACE("(%p, %p): pDesc:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC(pDesc));
@@ -344,21 +347,48 @@
strcpyW(p, pDesc->wszFileName);
}
/* 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 */
- 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) {
/* 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 */
- 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) {
/* 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 */
- 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 {
ERR(": no way to get additional info\n");
More information about the wine-patches
mailing list