[SF#645] Fix incorrect cycle in netproc_devicelist_clear()
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 1 May 2015 17:03:45 +0000 (20:03 +0300)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 1 May 2015 17:03:45 +0000 (20:03 +0300)
Invalid reference pointer lead to crash in netstat plugin on resume after suspend.

TODO
plugins/netstat/devproc.c

diff --git a/TODO b/TODO
index 5dc1365..1675b4c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -6,6 +6,7 @@
 * 'volumealsa' improvements
 * compose new custom launcher in launchbar config dialog
 * special launchers support ()
+* launchbar template with LockScreen and Shutdown
 * manage invisible panel from unplugged monitor
 * hotkeys for launchers
 * support rounded corners
index f6ff7c0..3ffb7ac 100644 (file)
@@ -475,34 +475,22 @@ static void netproc_alive(NETDEVLIST_PTR netdev_list)
 void netproc_devicelist_clear(NETDEVLIST_PTR *netdev_list)
 {
        NETDEVLIST_PTR ptr;
-       NETDEVLIST_PTR prev_ptr;
-       NETDEVLIST_PTR del_ptr;
+       NETDEVLIST_PTR next_ptr;
 
-       if (*netdev_list==NULL) {
-               return;
-       }
-
-       prev_ptr = NULL;
-       ptr = *netdev_list;
-       do {
+       for (ptr = *netdev_list; ptr != NULL; ptr = next_ptr) {
+               next_ptr = ptr->next;
                if (!ptr->info.alive) { /* if device was removed */
-                       if (prev_ptr!=NULL) {
+                       if (ptr->prev != NULL)
                                ptr->prev->next = ptr->next;
+                       if (ptr->next != NULL)
                                ptr->next->prev = ptr->prev;
-                       } else {
-                               ptr->next->prev = NULL;
+                       if (ptr == *netdev_list)
                                *netdev_list = ptr->next;
-                       }
 
-                       del_ptr = ptr;
-                       ptr = ptr->next;
-                       netproc_netdevlist_destroy(del_ptr);
-                       g_free(del_ptr);
-               } else {
-                       prev_ptr = ptr;
-                       ptr = ptr->next;
+                       netproc_netdevlist_destroy(ptr);
+                       g_free(ptr);
                }
-       } while(ptr!=NULL);
+       }
 }
 
 void netproc_listener(FNETD *fnetd)