Commit e6da2aec authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

gameux: Free the allocated GameStatisticsImpl object on failure in…

gameux: Free the allocated GameStatisticsImpl object on failure in GameStatisticsMgrImpl::GetGameStatistics. Spotted with Valgrind.
parent 3e2bf8ad
......@@ -1086,7 +1086,8 @@ static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_GetGameStatistics(
{
HRESULT hr;
WCHAR lpApplicationId[49];
GameStatisticsImpl *statisticsImpl;
GameStatisticsImpl *statisticsImpl = NULL;
IGameStatistics *output_iface;
TRACE("(%p, %s, 0x%x, %p, %p)\n", iface, debugstr_w(GDFBinaryPath), openType, pOpenResult, ppiStats);
......@@ -1097,13 +1098,21 @@ static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_GetGameStatistics(
if(SUCCEEDED(hr))
{
*ppiStats = IGameStatistics_from_impl(statisticsImpl);
output_iface = IGameStatistics_from_impl(statisticsImpl);
hr = GAMEUX_buildStatisticsFilePath(lpApplicationId, statisticsImpl->stats.sStatsFile);
}
if(SUCCEEDED(hr))
hr = GAMEUX_loadGameStatistics(&statisticsImpl->stats, lpApplicationId, openType, pOpenResult);
if(SUCCEEDED(hr))
*ppiStats = output_iface;
else
{
HeapFree(GetProcessHeap(), 0, statisticsImpl);
*ppiStats = NULL;
}
return hr;
}
......
......@@ -225,7 +225,7 @@ static void test_gamestatisticsmgr( void )
WORD wMaxStatsPerCategory = 0, wMaxCategories = 0;
IGameStatisticsMgr* gsm = NULL;
IGameStatistics* gs = NULL;
IGameStatistics* gs;
hr = CoCreateInstance( &CLSID_GameStatistics, NULL, CLSCTX_INPROC_SERVER, &IID_IGameStatisticsMgr, (LPVOID*)&gsm);
ok(hr == S_OK, "IGameStatisticsMgr creating failed (result false)\n");
......@@ -233,8 +233,10 @@ static void test_gamestatisticsmgr( void )
/* test trying to create interface IGameStatistics using GetGameStatistics method */
/* this should fail, cause statistics doesn't yet exists */
gs = (void *)0xdeadbeef;
hr = IGameStatisticsMgr_GetGameStatistics(gsm, sExeName, GAMESTATS_OPEN_OPENONLY, &dwOpenResult, &gs);
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "GetGameStatistics returned unexpected value: 0x%08x\n", hr);
ok(gs == NULL, "Expected output pointer to be NULL, got %p\n", gs);
/* now, allow to create */
hr = IGameStatisticsMgr_GetGameStatistics(gsm, sExeName, GAMESTATS_OPEN_OPENORCREATE, &dwOpenResult, &gs);
......
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