On Fri, Jun 06, 2014 at 09:11:58AM +0800, Amos Kong wrote: > +void qmp_exec_hmp_cmd(const char *expected_ret, const char *fmt, ...) > +{ > + va_list ap; > + char cmd[1024]; > + char *escaped_cmd; > + QDict *response; > + const char *response_return; > + > + va_start(ap, fmt); > + vsprintf(cmd, fmt, ap); > + va_end(ap); > + > + escaped_cmd = g_strescape(cmd, NULL); > + response = qmp("{\"execute\": \"human-monitor-command\"," > + " \"arguments\": {" > + " \"command-line\": \"%s\"" > + "}}", escaped_cmd); > + free(escaped_cmd);
glib uses g_malloc()/g_free() instead of malloc()/free(). Please use g_free() since the string comes from g_strescape().