diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6dee9d8326bc7a1ca3bf9932ed3a05ba50225a4d..426637ce48dd78ce9bdf277e2259abf5c0f534df 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1330,16 +1330,14 @@ int qemuCapsParseHelpStr(const char *qemu, fail: p = strchr(help, '\n'); - if (p) - p = strndup(help, p - help); + if (!p) + p = strchr(help, '\0'); qemuReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse %s version number in '%s'"), - qemu, p ? p : help); + _("cannot parse %s version number in '%.*s'"), + qemu, (int) (p - help), help); cleanup: - VIR_FREE(p); - return -1; }