server: fix a new double free()

By reorganizing the free() of the service and its subfields, the
patch reported in 'fixes' exposes a new double free().
Issue detected by 'scan-build'.

Fix it.

Fixes: 5ff384be08 ("semihosting: fix memory leak and double free")
Change-Id: Ief4262e98c9ecdca39d4e2d77e7a0ea87cfa198c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/9266
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
Antonio Borneo
2025-11-22 22:03:10 +01:00
parent fc8f939d95
commit 171454fffa

View File

@@ -378,7 +378,6 @@ int remove_service(const char *name, const char *port)
if (tmp->type != CONNECTION_STDINOUT)
close_socket(tmp->fd);
free(tmp->priv);
free_service(tmp);
return ERROR_OK;