[USERSRV] HardError: Free WindowTitleU buffer only if we really allocated it.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 9 Jun 2018 13:37:54 +0000 (15:37 +0200)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 9 Jun 2018 13:37:54 +0000 (15:37 +0200)
win32ss/user/winsrv/usersrv/harderror.c

index 7cc3a67..85ef9fe 100644 (file)
@@ -641,8 +641,10 @@ UserpFormatMessages(
     CaptionStringU->Length = (USHORT)(wcslen(CaptionStringU->Buffer) * sizeof(WCHAR));
 
     /* Free the strings if needed */
-    if (WindowTitleU.Buffer) RtlFreeUnicodeString(&WindowTitleU);
-    if (hProcess) RtlFreeUnicodeString(&FileNameU);
+    if (WindowTitleU.Buffer && (WindowTitleU.MaximumLength != 0))
+        RtlFreeUnicodeString(&WindowTitleU);
+    if (hProcess)
+        RtlFreeUnicodeString(&FileNameU);
 
     Format2A.Buffer = NULL;