git: ad3da82996ff - main - bhyve: plug memory leak in topology_parse()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 24 Feb 2022 17:42:09 UTC
The branch main has been updated by rew:
URL: https://cgit.FreeBSD.org/src/commit/?id=ad3da82996ffe8a7959fda4a84374b1907ebb116
commit ad3da82996ffe8a7959fda4a84374b1907ebb116
Author: Andy Fiddaman <andy@omniosce.org>
AuthorDate: 2022-02-24 17:36:41 +0000
Commit: Robert Wing <rew@FreeBSD.org>
CommitDate: 2022-02-24 17:38:53 +0000
bhyve: plug memory leak in topology_parse()
Reviewed by: jhb, rew
Differential Revision: https://reviews.freebsd.org/D34301
---
usr.sbin/bhyve/bhyverun.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 21ef18531e63..734239b38a8b 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -270,7 +270,7 @@ usage(int code)
static int
topology_parse(const char *opt)
{
- char *cp, *str;
+ char *cp, *str, *tofree;
if (*opt == '\0') {
set_config_value("sockets", "1");
@@ -280,7 +280,7 @@ topology_parse(const char *opt)
return (0);
}
- str = strdup(opt);
+ tofree = str = strdup(opt);
if (str == NULL)
errx(4, "Failed to allocate memory");
@@ -302,11 +302,11 @@ topology_parse(const char *opt)
else
set_config_value("cpus", cp);
}
- free(str);
+ free(tofree);
return (0);
out:
- free(str);
+ free(tofree);
return (-1);
}