Fix integer overflow on 32 bit, for `procmem`

pull/595/head
jackun 3 years ago
parent 361641382c
commit 94a7705554
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -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)

@ -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;

Loading…
Cancel
Save