aboutsummaryrefslogtreecommitdiffstats
path: root/lib/os_mon/c_src/memsup.c
diff options
context:
space:
mode:
authorAnton Vorobev <[email protected]>2011-11-08 19:28:00 +0100
committerHenrik Nord <[email protected]>2011-11-15 11:31:04 +0100
commita95ebdd1232122d168931f55c9863960316576e2 (patch)
tree99ce03126cd93e82121355acbfed26952c0d4f27 /lib/os_mon/c_src/memsup.c
parent6acdb64f208e26d78c7f55e6206b75b948e63daa (diff)
downloadotp-a95ebdd1232122d168931f55c9863960316576e2.tar.gz
otp-a95ebdd1232122d168931f55c9863960316576e2.tar.bz2
otp-a95ebdd1232122d168931f55c9863960316576e2.zip
Fix segmentation fault in memsup
when /proc/meminfo does not include information about buffers/cache (for instance inside OpenVZ container)
Diffstat (limited to 'lib/os_mon/c_src/memsup.c')
-rw-r--r--lib/os_mon/c_src/memsup.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/os_mon/c_src/memsup.c b/lib/os_mon/c_src/memsup.c
index 241e7718db..b6e417eaa0 100644
--- a/lib/os_mon/c_src/memsup.c
+++ b/lib/os_mon/c_src/memsup.c
@@ -327,27 +327,27 @@ get_mem_procfs(memory_ext *me){
/* Total and free is NEEDED! */
bp = strstr(buffer, "MemTotal:");
- if (sscanf(bp, "MemTotal: %lu kB\n", &(me->total))) me->flag |= F_MEM_TOTAL;
+ if (bp != NULL && sscanf(bp, "MemTotal: %lu kB\n", &(me->total))) me->flag |= F_MEM_TOTAL;
bp = strstr(buffer, "MemFree:");
- if (sscanf(bp, "MemFree: %lu kB\n", &(me->free))) me->flag |= F_MEM_FREE;
+ if (bp != NULL && sscanf(bp, "MemFree: %lu kB\n", &(me->free))) me->flag |= F_MEM_FREE;
/* Extensions */
bp = strstr(buffer, "Buffers:");
- if (sscanf(bp, "Buffers: %lu kB\n", &(me->buffered))) me->flag |= F_MEM_BUFFERS;
+ if (bp != NULL && sscanf(bp, "Buffers: %lu kB\n", &(me->buffered))) me->flag |= F_MEM_BUFFERS;
bp = strstr(buffer, "Cached:");
- if (sscanf(bp, "Cached: %lu kB\n", &(me->cached))) me->flag |= F_MEM_CACHED;
+ if (bp != NULL && sscanf(bp, "Cached: %lu kB\n", &(me->cached))) me->flag |= F_MEM_CACHED;
/* Swap */
bp = strstr(buffer, "SwapTotal:");
- if (sscanf(bp, "SwapTotal: %lu kB\n", &(me->total_swap))) me->flag |= F_SWAP_TOTAL;
+ if (bp != NULL && sscanf(bp, "SwapTotal: %lu kB\n", &(me->total_swap))) me->flag |= F_SWAP_TOTAL;
bp = strstr(buffer, "SwapFree:");
- if (sscanf(bp, "SwapFree: %lu kB\n", &(me->free_swap))) me->flag |= F_SWAP_FREE;
+ if (bp != NULL && sscanf(bp, "SwapFree: %lu kB\n", &(me->free_swap))) me->flag |= F_SWAP_FREE;
me->pagesize = 1024; /* procfs defines its size in kB */