Fix memory leak in colo-compare.c and filter-rewriter.c
Report by Coverity.

Signed-off-by: Zhang Chen <zhangchen.f...@cn.fujitsu.com>
---
 net/colo-compare.c    | 4 ++--
 net/filter-rewriter.c | 9 +++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index 22b1da1..47e7ebe 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -235,8 +235,8 @@ static int colo_packet_compare_tcp(Packet *spkt, Packet 
*ppkt)
         fprintf(stderr, "Secondary len = %d\n", spkt->size);
         qemu_hexdump((char *)spkt->data, stderr, "colo-compare", spkt->size);
 
-        g_free(sdebug);
-        g_free(ddebug);
+        free(sdebug);
+        free(ddebug);
     }
 
     return res;
diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c
index 89abe72..396a03c 100644
--- a/net/filter-rewriter.c
+++ b/net/filter-rewriter.c
@@ -75,8 +75,8 @@ static int handle_primary_tcp_pkt(NetFilterState *nf,
                     ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
                     tcp_pkt->th_flags);
         trace_colo_filter_rewriter_conn_offset(conn->offset);
-        g_free(sdebug);
-        g_free(ddebug);
+        free(sdebug);
+        free(ddebug);
     }
 
     if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) {
@@ -123,8 +123,8 @@ static int handle_secondary_tcp_pkt(NetFilterState *nf,
                     ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack),
                     tcp_pkt->th_flags);
         trace_colo_filter_rewriter_conn_offset(conn->offset);
-        g_free(sdebug);
-        g_free(ddebug);
+        free(sdebug);
+        free(ddebug);
     }
 
     if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == (TH_ACK | TH_SYN))) {
@@ -162,6 +162,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf,
 
     iov_to_buf(iov, iovcnt, 0, buf, size);
     pkt = packet_new(buf, size);
+    g_free(buf);
 
     /*
      * if we get tcp packet
-- 
2.7.4




Reply via email to