Author: janderwald
Date: Sun Sep 20 19:44:52 2009
New Revision: 43097
URL:
http://svn.reactos.org/svn/reactos?rev=43097&view=rev
Log:
- Fix a crash when an application hasnt defined a event label
Modified:
trunk/reactos/dll/cpl/mmsys/sounds.c
Modified: trunk/reactos/dll/cpl/mmsys/sounds.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/sounds.c?rev…
==============================================================================
--- trunk/reactos/dll/cpl/mmsys/sounds.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/mmsys/sounds.c [iso-8859-1] Sun Sep 20 19:44:52 2009
@@ -66,6 +66,8 @@
while(pMap)
{
+ ASSERT(pMap);
+ ASSERT(pMap->szName);
if (!_tcscmp(pMap->szName, szName))
return pMap;
@@ -77,6 +79,8 @@
while(pMap)
{
+ ASSERT(pMap);
+ ASSERT(pMap->szName);
if (!_tcscmp(pMap->szName, szName))
return pMap;
@@ -84,8 +88,21 @@
}
-
- return NULL;
+ pMap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LABEL_MAP));
+ if (!pMap)
+ return NULL;
+
+ pMap->szName = pMap->szDesc = _tcsdup(szName);
+ if (!pMap->szName)
+ {
+ HeapFree(GetProcessHeap(), 0, pMap);
+ return NULL;
+ }
+ pMap->AppMap = pAppMap;
+ pMap->Next = s_Map;
+ s_Map = pMap;
+
+ return pMap;
}
VOID RemoveLabel(PLABEL_MAP pMap)
@@ -206,7 +223,7 @@
return FALSE;
}
- pMap = HeapAlloc(GetProcessHeap(), 0, sizeof(LABEL_MAP));
+ pMap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LABEL_MAP));
if (!pMap)
{
return FALSE;
@@ -492,10 +509,9 @@
{
return FALSE;
}
-
- //MessageBox(hwndDlg, szLabelName, szAppName, MB_OK);
-
- pLabel = FindLabel(NULL, szLabelName);
+ pLabel = FindLabel(pAppMap, szLabelName);
+
+ ASSERT(pLabel);
RemoveLabel(pLabel);
pLabel->AppMap = pAppMap;