env/dpdk: fix potential memleak on init failure

When we were trying to push a newly allocated string
into the arg array and the array realloc() failed,
the string we were about to insert was leaked.

Change-Id: I31ccd5a09956d5407b2938792ecc9b482b2419d1
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/445149
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2019-02-18 15:40:26 +01:00
parent df99e28158
commit 9858408b55

View File

@ -162,6 +162,7 @@ spdk_push_arg(char *args[], int *argcount, char *arg)
tmp = realloc(args, sizeof(char *) * (*argcount + 1)); tmp = realloc(args, sizeof(char *) * (*argcount + 1));
if (tmp == NULL) { if (tmp == NULL) {
free(arg);
spdk_free_args(args, *argcount); spdk_free_args(args, *argcount);
return NULL; return NULL;
} }