fix handle leaks

svn path=/trunk/; revision=67305
This commit is contained in:
Christoph von Wittich 2015-04-19 19:28:03 +00:00
parent ece1ba5016
commit 3804a6e321
3 changed files with 21 additions and 9 deletions

View file

@ -26,7 +26,7 @@
b[0] = '\0';
LIST_ENTRY CachedEntriesHead = { &CachedEntriesHead, &CachedEntriesHead };
PLIST_ENTRY pCachedEntry = NULL;
PLIST_ENTRY pCachedEntry = &CachedEntriesHead;
BOOL
ShowAvailableAppInfo(INT Index)
@ -151,13 +151,6 @@ EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc)
PAPPLICATION_INFO Info;
HRESULT hr;
/* initialize the cached list if hasn't been yet */
if (pCachedEntry == NULL)
{
InitializeListHead(&CachedEntriesHead);
pCachedEntry = &CachedEntriesHead;
}
if (!GetStorageDirectory(szPath, _countof(szPath)))
return FALSE;

View file

@ -282,7 +282,19 @@ EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc)
if (!lpEnumProc(ItemIndex, pszDisplayName, &Info))
break;
}
else
{
RegCloseKey(Info.hSubKey);
}
}
else
{
RegCloseKey(Info.hSubKey);
}
}
else
{
RegCloseKey(Info.hSubKey);
}
}

View file

@ -127,10 +127,17 @@ EnumInstalledAppProc(INT ItemIndex, LPWSTR lpName, PINSTALLED_INFO Info)
INT Index;
if (!SearchPatternMatch(lpName, szSearchPattern))
{
RegCloseKey(Info->hSubKey);
return TRUE;
}
ItemInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(INSTALLED_INFO));
if (!ItemInfo) return FALSE;
if (!ItemInfo)
{
RegCloseKey(Info->hSubKey);
return FALSE;
}
RtlCopyMemory(ItemInfo, Info, sizeof(INSTALLED_INFO));