From: Sebastien GODARD Date: Sun, 6 Feb 2022 16:51:30 +0000 (+0100) Subject: sar/sadf: Don't reallocate buffers for activities not present in file X-Git-Tag: v12.5.6~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ab10c88f6835b90145174f6c0a467f317bdb160;p=sysstat 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 --- 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); }