From: Wang Yechao <wang.yechao...@zte.com.cn> The $GuestExecInfo.out.data is alloced in guest_exec_output_watch(), and the buffer size is $GuestExecInfo.out.size. We should free the $GuestExecInfo.out.data judge by the size, not length. Because the $GuestExecInfo.out.length maybe zero in some case.
$GuestExecInfo.err.data has the same problem. Signed-off-by: Yechao Wang <wang.yechao...@zte.com.cn> Signed-off-by: Yi Wang <wang.y...@zte.com.cn> --- qga/commands.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qga/commands.c b/qga/commands.c index d3fec80..58d4da9 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -214,17 +214,21 @@ GuestExecStatus *qmp_guest_exec_status(int64_t pid, Error **errp) if (gei->out.length > 0) { ges->has_out_data = true; ges->out_data = g_base64_encode(gei->out.data, gei->out.length); - g_free(gei->out.data); ges->has_out_truncated = gei->out.truncated; } if (gei->err.length > 0) { ges->has_err_data = true; ges->err_data = g_base64_encode(gei->err.data, gei->err.length); - g_free(gei->err.data); ges->has_err_truncated = gei->err.truncated; } + if (gei->out.size > 0) + g_free(gei->out.data); + + if (gei->err.size > 0) + g_free(gei->err.data); + QTAILQ_REMOVE(&guest_exec_state.processes, gei, next); g_free(gei); } -- 1.8.3.1