From cf8c618be3331b92d2844d0bf93b15060149ef7f 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 files changed, 16 insertions(+), 0 deletions(-) diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 8d09967..454bd3c 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) { -- 1.5.4.5