Module: wine Branch: master Commit: 0bbd6cb0506bbd820dd9486e24518f81ed02c883 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0bbd6cb0506bbd820dd9486e24...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Apr 2 21:47:32 2013 +0400
gameux: Fix release/free of uninitialized pointers (Coverity).
---
dlls/gameux/gameexplorer.c | 4 +++- dlls/gameux/gamestatistics.c | 15 ++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/dlls/gameux/gameexplorer.c b/dlls/gameux/gameexplorer.c index 8f30601..8400c9e 100644 --- a/dlls/gameux/gameexplorer.c +++ b/dlls/gameux/gameexplorer.c @@ -681,7 +681,7 @@ static HRESULT GAMEUX_UpdateGame(LPGUID InstanceID) { HRESULT hr; GAME_INSTALL_SCOPE installScope; LPWSTR lpRegistryPath; - LPWSTR lpGDFBinaryPath, lpGameInstallDirectory; + LPWSTR lpGDFBinaryPath;
TRACE("(%s)\n", debugstr_guid(InstanceID));
@@ -702,6 +702,8 @@ static HRESULT GAMEUX_UpdateGame(LPGUID InstanceID) {
if(SUCCEEDED(hr)) { + WCHAR *lpGameInstallDirectory = NULL; + /* game found, it's registry path is in lpRegistryPath and install * scope in installScope */ TRACE("game found in registry (path %s), updating\n", debugstr_w(lpRegistryPath)); diff --git a/dlls/gameux/gamestatistics.c b/dlls/gameux/gamestatistics.c index 619c616..54115f1 100644 --- a/dlls/gameux/gamestatistics.c +++ b/dlls/gameux/gamestatistics.c @@ -112,7 +112,7 @@ static HRESULT GAMEUX_updateStatisticsFile(struct GAMEUX_STATS *stats)
HRESULT hr = S_OK; IXMLDOMDocument *document; - IXMLDOMElement *root, *categoryElement, *statisticsElement; + IXMLDOMElement *root, *statisticsElement; IXMLDOMNode *categoryNode, *statisticsNode; VARIANT vStatsFilePath, vValue; BSTR bstrStatistics = NULL, bstrCategory = NULL, bstrIndex = NULL, @@ -178,6 +178,8 @@ static HRESULT GAMEUX_updateStatisticsFile(struct GAMEUX_STATS *stats) if(SUCCEEDED(hr)) for(i=0; i<MAX_CATEGORIES; ++i) { + IXMLDOMElement *categoryElement = NULL; + if(lstrlenW(stats->categories[i].sName)==0) continue;
@@ -187,7 +189,7 @@ static HRESULT GAMEUX_updateStatisticsFile(struct GAMEUX_STATS *stats) hr = IXMLDOMDocument_createNode(document, vValue, bstrCategory, NULL, &categoryNode);
if(SUCCEEDED(hr)) - hr = IXMLDOMNode_QueryInterface(categoryNode, &IID_IXMLDOMElement, (LPVOID*)&categoryElement); + hr = IXMLDOMNode_QueryInterface(categoryNode, &IID_IXMLDOMElement, (void**)&categoryElement);
V_INT(&vValue) = i; if(SUCCEEDED(hr)) @@ -207,6 +209,9 @@ static HRESULT GAMEUX_updateStatisticsFile(struct GAMEUX_STATS *stats) hr = IXMLDOMElement_setAttribute(categoryElement, bstrName, vValue); }
+ if (categoryElement) + IXMLDOMElement_Release(categoryElement); + SysFreeString(V_BSTR(&vValue));
if(SUCCEEDED(hr)) @@ -269,7 +274,6 @@ static HRESULT GAMEUX_updateStatisticsFile(struct GAMEUX_STATS *stats) if(SUCCEEDED(hr)) hr = IXMLDOMElement_appendChild(root, categoryNode, &categoryNode);
- IXMLDOMElement_Release(categoryElement); IXMLDOMNode_Release(categoryNode);
if(FAILED(hr)) @@ -939,16 +943,13 @@ static HRESULT WINAPI GameStatisticsImpl_Save( BOOL trackChanges) { GameStatisticsImpl *This = impl_from_IGameStatistics(iface); - HRESULT hr = S_OK;
TRACE("(%p, %d)\n", This, trackChanges);
if(trackChanges) FIXME("tracking changes not yet implemented\n");
- hr = GAMEUX_updateStatisticsFile(&This->stats); - - return hr; + return GAMEUX_updateStatisticsFile(&This->stats); }
static HRESULT WINAPI GameStatisticsImpl_SetLastPlayedCategory(