{
if (virJSONValueObjectHasKey(reply, "error")) {
virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
- char *cmdstr = virJSONValueToString(cmd, false);
- char *replystr = virJSONValueToString(reply, false);
+ g_autofree char *cmdstr = virJSONValueToString(cmd, false);
+ g_autofree char *replystr = virJSONValueToString(reply, false);
/* Log the full JSON formatted command & error */
VIR_DEBUG("unable to execute QEMU command %s: %s",
qemuMonitorJSONCommandName(cmd),
qemuMonitorJSONStringifyError(error));
- VIR_FREE(cmdstr);
- VIR_FREE(replystr);
return -1;
} else if (!virJSONValueObjectHasKey(reply, "return")) {
- char *cmdstr = virJSONValueToString(cmd, false);
- char *replystr = virJSONValueToString(reply, false);
+ g_autofree char *cmdstr = virJSONValueToString(cmd, false);
+ g_autofree char *replystr = virJSONValueToString(reply, false);
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
NULLSTR(cmdstr), NULLSTR(replystr));
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to execute QEMU command '%s'"),
qemuMonitorJSONCommandName(cmd));
- VIR_FREE(cmdstr);
- VIR_FREE(replystr);
return -1;
}
return 0;