From 1c31f6225f41dd2bd371571e829fbf6855788d24 Mon Sep 17 00:00:00 2001 From: panciyan Date: Fri, 31 Mar 2023 15:12:08 +0000 Subject: [PATCH] src/server: Fix memory leak of reg_list memory leak of reg_list when local_list realloc fail. Signed-off-by: panciyan Change-Id: I6b09137ecd132ab326205f5a575a38bcc82e8469 Reviewed-on: https://review.openocd.org/c/openocd/+/7566 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/server/gdb_server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index d8dbc2c8b..b15a6c1c3 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2348,6 +2348,7 @@ static int smp_reg_list_noread(struct target *target, local_list = realloc(local_list, combined_allocated * sizeof(struct reg *)); if (!local_list) { LOG_ERROR("realloc(%zu) failed", combined_allocated * sizeof(struct reg *)); + free(reg_list); return ERROR_FAIL; } }