From 94a7705554dc860150349fc8ab307720660c66fb Mon Sep 17 00:00:00 2001 From: jackun Date: Sun, 8 Aug 2021 17:21:45 +0300 Subject: [PATCH] Fix integer overflow on 32 bit, for `procmem` --- src/memory.cpp | 4 ++-- src/memory.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/memory.cpp b/src/memory.cpp index 9102352e..c360e976 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -114,8 +114,8 @@ void update_procmem() static auto pageSize = sysconf(_SC_PAGESIZE); if (pageSize < 0) pageSize = 4096; - long int temp[7]; - if (fscanf(statm, "%ld %ld %ld %ld %ld %ld %ld", + long long int temp[7]; + if (fscanf(statm, "%lld %lld %lld %lld %lld %lld %lld", &temp[0], &temp[1], &temp[2], &temp[3], &temp[4], /* unused since Linux 2.6; always 0 */ &temp[5], &temp[6]) == 7) diff --git a/src/memory.h b/src/memory.h index c48603ac..33fe846f 100644 --- a/src/memory.h +++ b/src/memory.h @@ -17,8 +17,8 @@ struct memory_information { struct process_mem { - float virt, resident, shared; - long int text, data, dirty; + int64_t virt, resident, shared; + int64_t text, data, dirty; }; extern process_mem proc_mem;