From 3ab10c88f6835b90145174f6c0a467f317bdb160 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 6 Feb 2022 17:51:30 +0100 Subject: [PATCH] sar/sadf: Don't reallocate buffers for activities not present in file Buffer reallocation would fail for activities which are not in the file being read. This is because @nr2 = -1 and @nr2 is used to compute the memory to allocate in reallocate_all_buffers(): SREALLOC(a->buf[j], void, (size_t) a->msize * nr_realloc * (size_t) a->nr2); Signed-off-by: Sebastien GODARD --- sa_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sa_common.c b/sa_common.c index 9b2d0c1..2046d17 100644 --- a/sa_common.c +++ b/sa_common.c @@ -2994,8 +2994,7 @@ int print_special_record(struct record_header *record_hdr, uint64_t l_flags, * not been collected in file (or if it has an unknown format). */ for (p = 0; p < NR_ACT; p++) { - if (HAS_PERSISTENT_VALUES(act[p]->options)) { - act[p]->nr_ini = file_hdr->sa_cpu_nr; + if (HAS_PERSISTENT_VALUES(act[p]->options) && (act[p]->nr_ini > 0)) { if (act[p]->nr_ini > act[p]->nr_allocated) { reallocate_all_buffers(act[p], act[p]->nr_ini); } -- 2.50.1