jtag/tcl: fix memory leak in error return

Clang static analyzer reported:
Warning:	line 196, column 3
Potential leak of memory pointed to by 'fields'

Free allocated memory pointed by 'fields' and fields[i].in_value

Change-Id: I0b3935d9a235544afc03e39a4648319047e65815
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5906
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
Reviewed-by: Jonathan McDowell <noodles-openocd@earth.li>
This commit is contained in:
Tomas Vanek 2020-10-29 20:41:54 +01:00 committed by Antonio Borneo
parent 49b7099def
commit 3099d52d78
1 changed files with 5 additions and 0 deletions

View File

@ -194,6 +194,11 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args
retval = jtag_execute_queue();
if (retval != ERROR_OK) {
Jim_SetResultString(interp, "drscan: jtag execute failed", -1);
for (i = 0; i < field_count; i++)
free(fields[i].in_value);
free(fields);
return JIM_ERR;
}