qemu: avoid double free of qemu help output

If yajl was not compiled in, we end up freeing an incoming
parameter, which leads to a bogus free later on.  Regression
introduced in commit 6e769eb.

* src/qemu/qemu_capabilities.c (qemuCapsParseHelpStr): Avoid alloc
on failure path, which in turn fixes bogus free.
Reported by Cole Robinson.
This commit is contained in:
Eric Blake 2012-01-27 13:53:11 -07:00
parent 93f93f5161
commit ab6f1c9814

View File

@ -1330,16 +1330,14 @@ int qemuCapsParseHelpStr(const char *qemu,
fail: fail:
p = strchr(help, '\n'); p = strchr(help, '\n');
if (p) if (!p)
p = strndup(help, p - help); p = strchr(help, '\0');
qemuReportError(VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse %s version number in '%s'"), _("cannot parse %s version number in '%.*s'"),
qemu, p ? p : help); qemu, (int) (p - help), help);
cleanup: cleanup:
VIR_FREE(p);
return -1; return -1;
} }