net/colo: fix memory double free error

The 'primary_list' and 'secondary_list' members of struct Connection
is not allocated through dynamically g_queue_new(), but we free it by using
g_queue_free(), which will lead to a double-free bug.

Reviewed-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
zhanghailiang 2017-02-28 11:54:18 +08:00 committed by Jason Wang
parent a11f5cb005
commit 0e79668e1f
1 changed files with 2 additions and 2 deletions

View File

@ -147,9 +147,9 @@ void connection_destroy(void *opaque)
Connection *conn = opaque; Connection *conn = opaque;
g_queue_foreach(&conn->primary_list, packet_destroy, NULL); g_queue_foreach(&conn->primary_list, packet_destroy, NULL);
g_queue_free(&conn->primary_list); g_queue_clear(&conn->primary_list);
g_queue_foreach(&conn->secondary_list, packet_destroy, NULL); g_queue_foreach(&conn->secondary_list, packet_destroy, NULL);
g_queue_free(&conn->secondary_list); g_queue_clear(&conn->secondary_list);
g_slice_free(Connection, conn); g_slice_free(Connection, conn);
} }