author | erik <erik> | 2007-01-24 19:54:07 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 19:54:07 (UTC) |
commit | 89e81059e832ff77c2f0ac8b9db12f80eafa03fc (patch) (unidiff) | |
tree | 99a130fc643d2aeefdecab452f644e7b61a5f50e /noncore/apps/opie-console/procctl.cpp | |
parent | 035bbc5bf689839c8d8e7be37f347b0dd900fccf (diff) | |
download | opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.zip opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.gz opie-89e81059e832ff77c2f0ac8b9db12f80eafa03fc.tar.bz2 |
Each file in this commit has an instance where a pointer is checked at
one point in the code and then not checked in another point in the code.
If it needed to be checked once, it needs to be checked the other time. If not
the application could segfault.
Diffstat (limited to 'noncore/apps/opie-console/procctl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/procctl.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp index a44529b..5239e26 100644 --- a/noncore/apps/opie-console/procctl.cpp +++ b/noncore/apps/opie-console/procctl.cpp | |||
@@ -28,49 +28,52 @@ void ProcCtl::add(pid_t pi, int fd ) { | |||
28 | con->prev = m_last; | 28 | con->prev = m_last; |
29 | 29 | ||
30 | m_last = con; | 30 | m_last = con; |
31 | 31 | ||
32 | } | 32 | } |
33 | void ProcCtl::remove( pid_t pi ) { | 33 | void ProcCtl::remove( pid_t pi ) { |
34 | /* | 34 | /* |
35 | * We first check if the last item | 35 | * We first check if the last item |
36 | * is equal to pi the we | 36 | * is equal to pi the we |
37 | * | 37 | * |
38 | */ | 38 | */ |
39 | ProcContainer* con; | 39 | ProcContainer* con; |
40 | if (m_last->pid == pi ) { | 40 | if (m_last->pid == pi ) { |
41 | con = m_last; | 41 | con = m_last; |
42 | m_last = con->prev; | 42 | m_last = con->prev; |
43 | delete con; | 43 | delete con; |
44 | return; | 44 | return; |
45 | } | 45 | } |
46 | 46 | ||
47 | con = m_last; | 47 | con = m_last; |
48 | ProcContainer* forw = 0l; | 48 | ProcContainer* forw = 0l; |
49 | while (con ) { | 49 | while (con ) { |
50 | /* remove it */ | 50 | /* remove it */ |
51 | if ( pi == con->pid ) { | 51 | if ( pi == con->pid ) { |
52 | forw->prev = con->prev; | 52 | if (forw) |
53 | forw->prev = con->prev; | ||
54 | else | ||
55 | forw = con->prev; | ||
53 | delete con; | 56 | delete con; |
54 | return; | 57 | return; |
55 | } | 58 | } |
56 | 59 | ||
57 | forw = con; | 60 | forw = con; |
58 | con = con->prev; | 61 | con = con->prev; |
59 | } | 62 | } |
60 | 63 | ||
61 | } | 64 | } |
62 | void ProcCtl::remove( ProcContainer con ) { | 65 | void ProcCtl::remove( ProcContainer con ) { |
63 | remove( con.pid ); | 66 | remove( con.pid ); |
64 | } | 67 | } |
65 | int ProcCtl::status(pid_t pid )const{ | 68 | int ProcCtl::status(pid_t pid )const{ |
66 | ProcContainer *con = m_last; | 69 | ProcContainer *con = m_last; |
67 | while (con) { | 70 | while (con) { |
68 | if (con->pid == pid ) | 71 | if (con->pid == pid ) |
69 | return con->status; | 72 | return con->status; |
70 | con = con->prev; | 73 | con = con->prev; |
71 | } | 74 | } |
72 | return -1; | 75 | return -1; |
73 | } | 76 | } |
74 | void ProcCtl::signal_handler(int) { | 77 | void ProcCtl::signal_handler(int) { |
75 | int status; | 78 | int status; |
76 | signal( SIGCHLD, signal_handler ); | 79 | signal( SIGCHLD, signal_handler ); |