diff options
author | Andy Fiddaman <andy@omniosce.org> | 2022-02-24 17:36:41 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2023-01-26 19:21:46 +0000 |
commit | 62bed9d49e418a48ca9bc36f5f7bc513c547c92f (patch) | |
tree | 76380e3cf27a6239d7a9bd7cbaf3ff03a849d462 | |
parent | 3737a0cdcb42f4495438997d4ff1655273c3016b (diff) |
bhyve: plug memory leak in topology_parse()
Reviewed by: jhb, rew
Differential Revision: https://reviews.freebsd.org/D34301
(cherry picked from commit ad3da82996ffe8a7959fda4a84374b1907ebb116)
-rw-r--r-- | usr.sbin/bhyve/bhyverun.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 4c2c07b934a7..70dd52c9b2b4 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -271,7 +271,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"); @@ -281,7 +281,7 @@ topology_parse(const char *opt) return (0); } - str = strdup(opt); + tofree = str = strdup(opt); if (str == NULL) errx(4, "Failed to allocate memory"); @@ -303,11 +303,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); } |