From 6a304370f831be0146b7cd007b3e9b8c3ea1b7a0 Mon Sep 17 00:00:00 2001 From: albert <> Date: Mon, 12 Sep 2005 03:25:01 +0000 Subject: [PATCH] ps: fix crash related to realloc -- thanks David Houlder --- NEWS | 1 + proc/readproc.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b0384d75..5ea998d7 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ top can do per-task display -- thanks John Blackwood rh114012 more MIPS crud -- thanks Jim Gifford and Ryan Oliver begin prep for setuid top: fix %CPU max on 2..9 CPU SMP -- thanks Ga*tan LEURENT +ps: fix crash related to realloc -- thanks David Houlder procps-3.2.4 --> procps-3.2.5 diff --git a/proc/readproc.c b/proc/readproc.c index 0c7315d3..e3245c1b 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -939,9 +939,11 @@ proc_data_t *readproctab2(int(*want_proc)(proc_t *buf), int(*want_task)(proc_t * for(;;){ proc_t *t; if(n_alloc == n_used){ - //proc_t *old = data; + proc_t *old = data; n_alloc = n_alloc*5/4+30; // grow by over 25% data = realloc(data,sizeof(proc_t)*n_alloc); + // have to move tmp too + tmp = data+(tmp-old); //if(!data) return NULL; } if(n_task_alloc == n_task){