From 4820619f15b02c6f40b8421e519af5ddcba624bc Mon Sep 17 00:00:00 2001
From: Jim Warner <james.warner@comcast.net>
Date: Thu, 6 Oct 2011 08:34:26 -0500
Subject: [PATCH] redhat analysis: proc/readproc

---
 proc/readproc.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/proc/readproc.c b/proc/readproc.c
index 4949704e..45ec4150 100644
--- a/proc/readproc.c
+++ b/proc/readproc.c
@@ -1112,15 +1112,13 @@ next_proc:
     }
 
 next_task:
-    for (;;) {
-        // fills in our path, plus x->tid and x->tgid
-        if ((!(PT->taskfinder(PT,&skel_p,x,path)))         // simple_nexttid
-        || (!(ret = PT->taskreader(PT,new_p,x,path)))) {   // simple_readtask
-            goto next_proc;
-        }
-        if (!new_p) new_p = ret;
-        return ret;
+    // fills in our path, plus x->tid and x->tgid
+    if ((!(PT->taskfinder(PT,&skel_p,x,path)))             // simple_nexttid
+    || (!(ret = PT->taskreader(PT,new_p,x,path)))) {       // simple_readtask
+        goto next_proc;
     }
+    if (!new_p) new_p = ret;
+    return ret;
 
 end_procs:
     if (!saved_x) free(x);
@@ -1152,7 +1150,7 @@ PROCTAB* openproc(int flags, ...) {
       PT->finder = listed_nextpid;
     }else{
       PT->procfs = opendir("/proc");
-      if(!PT->procfs) return NULL;
+      if(!PT->procfs) { free(PT); return NULL; }
       PT->finder = simple_nextpid;
     }
     PT->flags = flags;
-- 
2.40.0