target/arm_tpiu_swo: Fix memory leak on error
In case of fail to allocate 'obj->name', the memory allocated for
'obj->out_filename' is not freed, thus leaking.
Since 'obj' is allocated with calloc(), thus zeroed, switch to use
the common error exit path for both allocations of 'obj->name' and
'obj->out_filename'.
Fixes: 2506ccb509
("target/arm_tpiu_swo: Fix division by zero")
Change-Id: I412f66ddd7bf7d260cee495324058482b26ff0c5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8300
Tested-by: jenkins
Reviewed-by: zapb <dev@zapb.de>
This commit is contained in:
parent
400cf213c0
commit
b49e03f77e
|
@ -965,8 +965,7 @@ static int jim_arm_tpiu_swo_create(Jim_Interp *interp, int argc, Jim_Obj *const
|
||||||
obj->out_filename = strdup("external");
|
obj->out_filename = strdup("external");
|
||||||
if (!obj->out_filename) {
|
if (!obj->out_filename) {
|
||||||
LOG_ERROR("Out of memory");
|
LOG_ERROR("Out of memory");
|
||||||
free(obj);
|
goto err_exit;
|
||||||
return JIM_ERR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Jim_Obj *n;
|
Jim_Obj *n;
|
||||||
|
@ -974,8 +973,7 @@ static int jim_arm_tpiu_swo_create(Jim_Interp *interp, int argc, Jim_Obj *const
|
||||||
obj->name = strdup(Jim_GetString(n, NULL));
|
obj->name = strdup(Jim_GetString(n, NULL));
|
||||||
if (!obj->name) {
|
if (!obj->name) {
|
||||||
LOG_ERROR("Out of memory");
|
LOG_ERROR("Out of memory");
|
||||||
free(obj);
|
goto err_exit;
|
||||||
return JIM_ERR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do the rest as "configure" options */
|
/* Do the rest as "configure" options */
|
||||||
|
|
Loading…
Reference in New Issue