target: fix memory leak on multiple '-gdb-port' flag
In the odd case of multiple flags '-gdb-port' during 'target create' or following 'configure', the new strdup()'ed value will replace the old one without freeing it. Free the old value (if it exists) before replacing it. Change-Id: I1673346613ce7023880046e3a9ba473e75f18b8a Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6005 Tested-by: jenkins
This commit is contained in:
parent
e22198c152
commit
c1270bcb38
|
@ -5123,6 +5123,7 @@ no_params:
|
|||
e = Jim_GetOpt_String(goi, &s, NULL);
|
||||
if (e != JIM_OK)
|
||||
return e;
|
||||
free(target->gdb_port_override);
|
||||
target->gdb_port_override = strdup(s);
|
||||
} else {
|
||||
if (goi->argc != 0)
|
||||
|
|
Loading…
Reference in New Issue