naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0081-ifstat-Fix-memleak-in-dump_kern_db-for-json-output.patch

36cfb7
From 3f74fdcd943982101775db3b4240a6f953d1198d Mon Sep 17 00:00:00 2001
36cfb7
From: Andrea Claudi <aclaudi@redhat.com>
36cfb7
Date: Mon, 29 Apr 2019 20:07:22 +0200
36cfb7
Subject: [PATCH] ifstat: Fix memleak in dump_kern_db() for json output
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
36cfb7
Upstream Status: iproute2.git commit b530cef0e3bbd
36cfb7
36cfb7
commit b530cef0e3bbd27510e19f5f720a7ec94f3fa723
36cfb7
Author: Phil Sutter <phil@nwl.cc>
36cfb7
Date:   Thu Aug 17 19:09:29 2017 +0200
36cfb7
36cfb7
    ifstat: Fix memleak in dump_kern_db() for json output
36cfb7
36cfb7
    Looks like this was forgotten when converting to common json output
36cfb7
    formatter.
36cfb7
36cfb7
    Fixes: fcc16c2287bf8 ("provide common json output formatter")
36cfb7
    Signed-off-by: Phil Sutter <phil@nwl.cc>
36cfb7
---
36cfb7
 misc/ifstat.c | 8 ++++++--
36cfb7
 1 file changed, 6 insertions(+), 2 deletions(-)
36cfb7
36cfb7
diff --git a/misc/ifstat.c b/misc/ifstat.c
36cfb7
index 8fa354265a9a1..1be21703bf14c 100644
36cfb7
--- a/misc/ifstat.c
36cfb7
+++ b/misc/ifstat.c
36cfb7
@@ -535,8 +535,12 @@ static void dump_kern_db(FILE *fp)
36cfb7
 		else
36cfb7
 			print_one_if(fp, n, n->val);
36cfb7
 	}
36cfb7
-	if (json_output)
36cfb7
-		fprintf(fp, "\n} }\n");
36cfb7
+	if (jw) {
36cfb7
+		jsonw_end_object(jw);
36cfb7
+
36cfb7
+		jsonw_end_object(jw);
36cfb7
+		jsonw_destroy(&jw;;
36cfb7
+	}
36cfb7
 }
36cfb7
 
36cfb7
 static void dump_incr_db(FILE *fp)
36cfb7
-- 
36cfb7
2.20.1
36cfb7