Fix UAF detected by asan
authorDavid Barksdale <amatus.amongus@gmail.com>
Mon, 5 Sep 2016 01:59:35 +0000 (01:59 +0000)
committerDavid Barksdale <amatus.amongus@gmail.com>
Mon, 5 Sep 2016 01:59:35 +0000 (01:59 +0000)
src/namestore/gnunet-service-namestore.c

index 05bcd94ce2dfef74f7d2cb3a0e9643bd88268d9a..effb33e5155e070f22fd61f38069e91528b21487 100644 (file)
@@ -340,13 +340,6 @@ client_disconnect_notification (void *cls,
              client);
   if (NULL == (nc = GNUNET_SERVER_client_get_user_context (client, struct NamestoreClient)))
     return;
-  while (NULL != (no = nc->op_head))
-  {
-    GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no);
-    GNUNET_free (no);
-  }
-  GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc);
-  GNUNET_free (nc);
   for (zm = monitor_head; NULL != zm; zm = zm->next)
   {
     if (client == zm->nc->client)
@@ -363,6 +356,13 @@ client_disconnect_notification (void *cls,
       break;
     }
   }
+  while (NULL != (no = nc->op_head))
+  {
+    GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no);
+    GNUNET_free (no);
+  }
+  GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc);
+  GNUNET_free (nc);
   for (cop = cop_head; NULL != cop; cop = cop->next)
     if (client == cop->client)
       cop->client = NULL;