From 1c1feb7db2b5e5c6fe44e221d6a031a6dbf7e851 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 20 Jul 2012 04:19:38 +0200 Subject: [PATCH] Fix a memory leak in top.c (sf.net #3543857) The leak was caused by commit 8827d61, attempting to solve a problem with top displaying 10th process incorrectly. I think there should be a more elegant solution to this, but I don't know how to find it atm (it could be due the fact that it's 4am here). --- src/top.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/top.c b/src/top.c index a53970ed..8fe62848 100644 --- a/src/top.c +++ b/src/top.c @@ -725,8 +725,11 @@ static void sp_acopy(struct sorted_process *sp_head, struct process **ar, int ma int x; sp_cur = sp_head; - for (x = 0; x < max_size && sp_cur != NULL; x++) { + for (x = 0; x < max_size && sp_cur != NULL; x++, sp_cur = sp_cur->less) ar[x] = sp_cur->proc; + + + for (sp_cur = sp_head; sp_cur != NULL;) { sp_tmp = sp_cur; sp_cur = sp_cur->less; free_sp(sp_tmp);