From a38e6c39d0450ed81f70ffae6b1d4fd18025d5d2 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 28 Sep 2007 20:19:15 +0000 Subject: [PATCH] [SIGAR-68] Fix possible segfault in cpu_list --- src/os/solaris/solaris_sigar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index a3ed2ec7..731c7a4d 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -453,13 +453,14 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist) /* merge times of logical processors */ ent = sigar_cache_get(chips, chip_id); if (ent->value) { - cpu = (sigar_cpu_t *)ent->value; + cpu = &cpulist->data[(int)ent->value]; } else { SIGAR_CPU_LIST_GROW(cpulist); + ent->value = (void *)(int)cpulist->number; cpu = &cpulist->data[cpulist->number++]; SIGAR_ZERO(cpu); - ent->value = cpu; + if (is_debug) { sigar_log_printf(sigar, SIGAR_LOG_DEBUG, "[cpu_list] Merging times of"