[POWERCFG] Fix an exception that occurs when the control panel is closed.
authorEric Kohl <eric.kohl@reactos.org>
Sat, 27 Apr 2019 17:00:33 +0000 (19:00 +0200)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 27 Apr 2019 17:01:35 +0000 (19:01 +0200)
dll/cpl/powercfg/powershemes.c

index 4fff28a..7d1441a 100644 (file)
@@ -78,8 +78,12 @@ AddPowerScheme(
                                         dwDescription + sizeof(TCHAR));
     if (pScheme->pszName == NULL || pScheme->pszDescription == NULL)
     {
-        HeapFree(GetProcessHeap(), 0, pScheme->pszName);
-        HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
+        if (pScheme->pszName)
+            HeapFree(GetProcessHeap(), 0, pScheme->pszName);
+
+        if (pScheme->pszDescription)
+            HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
+
         HeapFree(GetProcessHeap(), 0, pScheme);
         return NULL;
     }
@@ -103,8 +107,12 @@ DeletePowerScheme(
 {
     RemoveEntryList(&pScheme->ListEntry);
 
-    HeapFree(GetProcessHeap(), 0, pScheme->pszName);
-    HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
+    if (pScheme->pszName)
+        HeapFree(GetProcessHeap(), 0, pScheme->pszName);
+
+    if (pScheme->pszDescription)
+        HeapFree(GetProcessHeap(), 0, pScheme->pszDescription);
+
     HeapFree(GetProcessHeap(), 0, pScheme);
 }