]> granicus.if.org Git - sysstat/commitdiff
sadf: Fix seg fault on empty data files
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 13 Apr 2019 16:44:29 +0000 (18:44 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 13 Apr 2019 16:44:29 +0000 (18:44 +0200)
Trying to display XML or JSON data (with sadf -x/-j) from a data file
containing only RESTART records created a core dump.
This patch fixes that.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
sadf.c

diff --git a/sadf.c b/sadf.c
index 9a56bd27eb555b87af9a176380e4656ff4490ced..2b058c82d48538f833042a22d72ecda9b88ab969 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -1074,14 +1074,15 @@ void logic1_display_loop(int ifd, char *file, struct file_activity *file_actlst,
                        (tm_start.use && (datecmp(loctime, &tm_start) < 0)) ||
                        (tm_end.use && (datecmp(loctime, &tm_end) >= 0))));
 
-               /* Save the first stats collected. Used for example in next_slice() function */
-               copy_structures(act, id_seq, record_hdr, 2, 0);
-
                curr = 1;
                cnt = count;
                reset = TRUE;
 
                if (!eosaf) {
+
+                       /* Save the first stats collected. Used for example in next_slice() function */
+                       copy_structures(act, id_seq, record_hdr, 2, 0);
+
                        do {
                                eosaf = read_next_sample(ifd, ign_flag, curr, file,
                                                         &rtype, tab, file_magic, file_actlst,