Lei Zhang : cmd: Check the return value from HeapAlloc.

Alexandre Julliard julliard at winehq.org
Wed Jul 30 08:36:02 CDT 2008


Module: wine
Branch: master
Commit: e6bce797d3b1f13495637862e1b01fc8e5b41e3c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e6bce797d3b1f13495637862e1b01fc8e5b41e3c

Author: Lei Zhang <thestig at google.com>
Date:   Mon Jul 28 14:45:21 2008 -0700

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) {




More information about the wine-cvs mailing list