This is an automated email from Gerrit.

Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/5906

-- gerrit

commit daedb5bbe8aa765cb49f66ab31a99d795961f407
Author: Tomas Vanek <[email protected]>
Date:   Thu Oct 29 20:41:54 2020 +0100

    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 <[email protected]>

diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c
index 153a98e..2fa162e 100644
--- a/src/jtag/tcl.c
+++ b/src/jtag/tcl.c
@@ -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;
        }
 

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to