diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index 8c8033249e0a..6e813a10001e 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -193,6 +193,7 @@ topology_parse(const char *opt) c = 1, n = 1, s = 1, t = 1; ns = false, scts = false; str = strdup(opt); + assert(str != NULL); while ((cp = strsep(&str, ",")) != NULL) { if (sscanf(cp, "%i%n", &tmp, &chk) == 1) { @@ -218,11 +219,13 @@ topology_parse(const char *opt) } else if (cp[0] == '\0') continue; else - return (-1); + goto out; /* Any trailing garbage causes an error */ if (cp[chk] != '\0') - return (-1); + goto out; } + free(str); + /* * Range check 1 <= n <= UINT16_MAX all values */ @@ -248,6 +251,10 @@ topology_parse(const char *opt) cores = c; threads = t; return(0); + +out: + free(str); + return (-1); } static int