From: Seung-Woo Kim Date: Mon, 10 Feb 2020 06:28:36 +0000 (+0900) Subject: Fix to check memory allocation failure X-Git-Tag: submit/tizen/20200210.075209^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=737d065c7fa0dc71223f6eb83dcb938b640dbea4;p=platform%2Fcore%2Fsystem%2Finitrd-flash.git Fix to check memory allocation failure The strdup() can be failed and return NULL. Not to access wrong memory, explictly check memory allocation failure. Change-Id: I2917cf0cebd6488004b653c29137c0acbb56074e Signed-off-by: Seung-Woo Kim --- diff --git a/src/main.c b/src/main.c index 80267db..32c2473 100644 --- a/src/main.c +++ b/src/main.c @@ -39,8 +39,13 @@ int _main(int argc, char *argv[]) if (opt_table) free(opt_table); opt_table = strdup(optarg); - if (opt_table) + if (opt_table) { part_table = opt_table; + } else { + fprintf(stderr, "Out of memory\n"); + ret = -1; + goto out; + } } else { fprintf(stderr, "path should be specified with '-i'\n");