target/semihosting_common: fix minor memory leak

Reported by clang static analyzer.

Change-Id: Ie663f49d92588c0d8b502cfdd8fc34004b308066
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5380
Reviewed-by: Liviu Ionescu <ilg@livius.net>
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
This commit is contained in:
Tomas Vanek 2019-12-20 23:48:46 +01:00
parent 57afa176ce
commit fe6bb7eac8
1 changed files with 2 additions and 0 deletions

View File

@ -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 {