From e6bce797d3b1f13495637862e1b01fc8e5b41e3c Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 28 Jul 2008 14:45:21 -0700 Subject: [PATCH] cmd: Check the return value from HeapAlloc. --- programs/cmd/wcmdmain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 8d09967f661..454bd3ccc9d 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -601,10 +601,21 @@ void WCMD_execute (WCHAR *command, WCHAR *redirects, /* Move copy of the command onto the heap so it can be expanded */ new_cmd = HeapAlloc( GetProcessHeap(), 0, MAXSTRING * sizeof(WCHAR)); + if (!new_cmd) + { + WINE_ERR("Could not allocate memory for new_cmd\n"); + return; + } strcpyW(new_cmd, command); /* Move copy of the redirects onto the heap so it can be expanded */ new_redir = HeapAlloc( GetProcessHeap(), 0, MAXSTRING * sizeof(WCHAR)); + if (!new_redir) + { + WINE_ERR("Could not allocate memory for new_redir\n"); + HeapFree( GetProcessHeap(), 0, new_cmd ); + return; + } /* If piped output, send stdout to the pipe by appending >filename to redirects */ if (piped) { @@ -2086,6 +2097,11 @@ WCHAR *WCMD_ReadAndParseLine(WCHAR *optionalcmd, CMD_LIST **output, HANDLE readF /* Allocate working space for a command read from keyboard, file etc */ if (!extraSpace) extraSpace = HeapAlloc(GetProcessHeap(), 0, (MAXSTRING+1) * sizeof(WCHAR)); + if (!extraSpace) + { + WINE_ERR("Could not allocate memory for extraSpace\n"); + return NULL; + } /* If initial command read in, use that, otherwise get input from handle */ if (optionalcmd != NULL) {