From fe6bb7eac8c7028236306c562d24a25ef79d0c15 Mon Sep 17 00:00:00 2001 From: Tomas Vanek Date: Fri, 20 Dec 2019 23:48:46 +0100 Subject: [PATCH] target/semihosting_common: fix minor memory leak Reported by clang static analyzer. Change-Id: Ie663f49d92588c0d8b502cfdd8fc34004b308066 Signed-off-by: Tomas Vanek Reviewed-on: http://openocd.zylin.com/5380 Reviewed-by: Liviu Ionescu Tested-by: jenkins Reviewed-by: Oleksij Rempel --- src/target/semihosting_common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c index ce6a791717..a41f8e4c88 100644 --- a/src/target/semihosting_common.c +++ b/src/target/semihosting_common.c @@ -944,6 +944,8 @@ int semihosting_common(struct target *target) uint8_t *fn1 = malloc(len1+1); uint8_t *fn2 = malloc(len2+1); if (!fn1 || !fn2) { + free(fn1); + free(fn2); semihosting->result = -1; semihosting->sys_errno = ENOMEM; } else { -- 2.30.2