]> granicus.if.org Git - nethack/commitdiff
Fix memory leak. See bug 1169.
authorBart House <bart@barthouse.com>
Sun, 13 May 2018 02:45:16 +0000 (19:45 -0700)
committerBart House <bart@barthouse.com>
Sun, 13 May 2018 02:45:16 +0000 (19:45 -0700)
win/win32/mhmain.c

index f64ab76650bdda7e70e3a95bf2e903d9a5949eaa..6c6bfea7dabb0289053758266756e13884ee020b 100644 (file)
@@ -795,6 +795,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
         if (!OpenClipboard(hWnd)) {
             NHMessageBox(hWnd, TEXT("Cannot open clipboard"),
                          MB_OK | MB_ICONERROR);
+            free(p);
             return 0;
         }
 
@@ -803,6 +804,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
         hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (len + 1) * sizeof(char));
         if (hglbCopy == NULL) {
             CloseClipboard();
+            free(p);
             return FALSE;
         }