]> granicus.if.org Git - sysstat/commitdiff
sar/sadf: Don't reallocate buffers for activities not present in file
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 6 Feb 2022 16:51:30 +0000 (17:51 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 6 Feb 2022 16:51:30 +0000 (17:51 +0100)
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 <sysstat@users.noreply.github.com>
sa_common.c

index 9b2d0c1cbdad07d467e972707fff0352bd375798..2046d17eb09794806ba7cbb3f9202012b8becff0 100644 (file)
@@ -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);
                                }