From 427d99e60f2a9b3b1e6b62b1d5fd36d6512f991b Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 18 Apr 2009 13:12:23 +0200 Subject: [PATCH] memory plugin: Check `pagesize' when initializing, not when reading. --- src/memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/memory.c b/src/memory.c index 0926c595..d6c3c888 100644 --- a/src/memory.c +++ b/src/memory.c @@ -87,6 +87,11 @@ static int memory_init (void) #elif HAVE_SYSCTL pagesize = getpagesize (); + if (pagesize <= 0) + { + ERROR ("memory plugin: Invalid pagesize: %i", pagesize); + return (-1); + } /* #endif HAVE_SYSCTL */ #elif HAVE_SYSCTLBYNAME @@ -187,12 +192,6 @@ static int memory_read (void) struct vmtotal vmtotal; size_t size; - if (pagesize <= 0) - { - ERROR ("memory plugin: Invalid pagesize: %i", pagesize); - return (-1); - } - memset (&vmtotal, 0, sizeof (vmtotal)); size = sizeof (vmtotal); @@ -203,6 +202,7 @@ static int memory_read (void) return (-1); } + assert (pagesize > 0); memory_submit ("active", vmtotal.t_arm * pagesize); memory_submit ("inactive", (vmtotal.t_rm - vmtotal.t_arm) * pagesize); memory_submit ("free", vmtotal.t_free * pagesize); -- 2.11.0