Blame SOURCES/0001-sadf-Fix-seg-fault-on-empty-data-files.patch

5bd5d3
From ce90f916fee2a39eb914f8b6b349adb76d100f75 Mon Sep 17 00:00:00 2001
5bd5d3
From: Sebastien GODARD <sysstat@users.noreply.github.com>
5bd5d3
Date: Sat, 13 Apr 2019 18:44:29 +0200
5bd5d3
Subject: [PATCH] sadf: Fix seg fault on empty data files
5bd5d3
5bd5d3
Trying to display XML or JSON data (with sadf -x/-j) from a data file
5bd5d3
containing only RESTART records created a core dump.
5bd5d3
This patch fixes that.
5bd5d3
5bd5d3
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
5bd5d3
---
5bd5d3
 sadf.c | 7 ++++---
5bd5d3
 1 file changed, 4 insertions(+), 3 deletions(-)
5bd5d3
5bd5d3
diff --git a/sadf.c b/sadf.c
5bd5d3
index 2d2c39c..5d558d3 100644
5bd5d3
--- a/sadf.c
5bd5d3
+++ b/sadf.c
5bd5d3
@@ -963,14 +963,15 @@ void logic1_display_loop(int ifd, struct file_activity *file_actlst, char *file,
5bd5d3
 			(tm_start.use && (datecmp(loctime, &tm_start) < 0)) ||
5bd5d3
 			(tm_end.use && (datecmp(loctime, &tm_end) >= 0))));
5bd5d3
 
5bd5d3
-		/* Save the first stats collected. Used for example in next_slice() function */
5bd5d3
-		copy_structures(act, id_seq, record_hdr, 2, 0);
5bd5d3
-
5bd5d3
 		curr = 1;
5bd5d3
 		cnt = count;
5bd5d3
 		reset = TRUE;
5bd5d3
 
5bd5d3
 		if (!eosaf) {
5bd5d3
+
5bd5d3
+		        /* Save the first stats collected. Used for example in next_slice() function */
5bd5d3
+		        copy_structures(act, id_seq, record_hdr, 2, 0);
5bd5d3
+
5bd5d3
 			do {
5bd5d3
 				eosaf = read_next_sample(ifd, IGNORE_COMMENT | IGNORE_RESTART, curr,
5bd5d3
 							 file, &rtype, tab, file_magic, file_actlst,
5bd5d3
-- 
5bd5d3
2.31.1
5bd5d3