From 2061c14c9bea67f8f1fc6bc7acb33c903a0586c1 Mon Sep 17 00:00:00 2001 From: Zhang Chen Date: Mon, 17 Oct 2016 17:23:59 +0800 Subject: colo-proxy: fix memory leak Fix memory leak in colo-compare.c and filter-rewriter.c Report by Coverity and add some comments. Signed-off-by: Zhang Chen Reviewed-by: zhanghailiang Signed-off-by: Jason Wang --- net/colo-compare.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'net/colo-compare.c') diff --git a/net/colo-compare.c b/net/colo-compare.c index 109990fd8e..f791383dbc 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -188,7 +188,6 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) { struct tcphdr *ptcp, *stcp; int res; - char *sdebug, *ddebug; trace_colo_compare_main("compare tcp"); if (ppkt->size != spkt->size) { @@ -219,24 +218,21 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet *ppkt) (spkt->size - ETH_HLEN)); if (res != 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { - sdebug = strdup(inet_ntoa(ppkt->ip->ip_src)); - ddebug = strdup(inet_ntoa(ppkt->ip->ip_dst)); - fprintf(stderr, "%s: src/dst: %s/%s p: seq/ack=%u/%u" - " s: seq/ack=%u/%u res=%d flags=%x/%x\n", - __func__, sdebug, ddebug, - (unsigned int)ntohl(ptcp->th_seq), - (unsigned int)ntohl(ptcp->th_ack), - (unsigned int)ntohl(stcp->th_seq), - (unsigned int)ntohl(stcp->th_ack), - res, ptcp->th_flags, stcp->th_flags); - - fprintf(stderr, "Primary len = %d\n", ppkt->size); - qemu_hexdump((char *)ppkt->data, stderr, "colo-compare", ppkt->size); - fprintf(stderr, "Secondary len = %d\n", spkt->size); - qemu_hexdump((char *)spkt->data, stderr, "colo-compare", spkt->size); - - g_free(sdebug); - g_free(ddebug); + trace_colo_compare_pkt_info(inet_ntoa(ppkt->ip->ip_src), + inet_ntoa(ppkt->ip->ip_dst), + ntohl(ptcp->th_seq), + ntohl(ptcp->th_ack), + ntohl(stcp->th_seq), + ntohl(stcp->th_ack), + res, ptcp->th_flags, + stcp->th_flags, + ppkt->size, + spkt->size); + + qemu_hexdump((char *)ppkt->data, stderr, + "colo-compare ppkt", ppkt->size); + qemu_hexdump((char *)spkt->data, stderr, + "colo-compare spkt", spkt->size); } return res; -- cgit v1.2.1