From: Tomas Vanek Date: Fri, 20 Dec 2019 22:48:46 +0000 (+0100) Subject: target/semihosting_common: fix minor memory leak X-Git-Tag: v0.11.0-rc1~506 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=fe6bb7eac8c7028236306c562d24a25ef79d0c15 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 --- 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 {