From 663a06aef989c85318fc0edd3dfd7463ee6552ac Mon Sep 17 00:00:00 2001 From: pengzhao Date: Tue, 18 Mar 2003 05:22:39 +0000 Subject: [PATCH] adding error handling in runas.c in case the malloc() fails --- lustre/tests/runas.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lustre/tests/runas.c b/lustre/tests/runas.c index 348ddb9..8731699 100644 --- a/lustre/tests/runas.c +++ b/lustre/tests/runas.c @@ -80,6 +80,11 @@ main(int argc, char**argv) // assemble the command my_argv = (char**)malloc(sizeof(char*)*(argc+1-optind)); + if(my_argv == NULL) { + fprintf(stderr, "Error in allocating memory. (%s)\n", strerror(errno)); + exit(-1); + } + for(i=optind; i< argc; i++) { my_argv[i-optind] = argv[i]; // printf("%s\n",my_argv[i-optind]); -- 1.8.3.1