This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8822

-- gerrit

commit 741e35bcaeb79ac2a76b29036f016b982087a3cd
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Sat Mar 29 22:51:59 2025 +0100

    target: fix memory leak in handle_target_write_memory()
    
    Commit f55ec6d44922 ("target: rewrite command 'write_memory' as
    COMMAND_HANDLER") adds a new return statement without freeing the
    allocated buffer.
    
    Add the needed free().
    
    Fixes: f55ec6d44922 ("target: rewrite command 'write_memory' as 
COMMAND_HANDLER")
    Change-Id: I676d658118b32f4d7cc71eda3436bb52f1966cd8
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/target/target.c b/src/target/target.c
index 2f736f0e8e..38f9a3d059 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -4608,6 +4608,7 @@ COMMAND_HANDLER(handle_target_write_memory)
                        int jimretval = Jim_GetWide(CMD_CTX->interp, tmp, 
&element_wide);
                        if (jimretval != JIM_OK) {
                                command_print(CMD, "invalid value \"%s\"", 
Jim_GetString(tmp, NULL));
+                               free(buffer);
                                return ERROR_COMMAND_ARGUMENT_INVALID;
                        }
 

-- 

Reply via email to