The NULL test clearly needs to be before any dereferences.
authorDavid Barksdale <amatus.amongus@gmail.com>
Thu, 30 Sep 2010 19:55:00 +0000 (19:55 +0000)
committerDavid Barksdale <amatus.amongus@gmail.com>
Thu, 30 Sep 2010 19:55:00 +0000 (19:55 +0000)
src/transport/transport_api.c

index 093c00bef8731ec243e152af15052a4dcdbc4e62..1eea40bb7da01e73b36bb5a6ec7dbede9ff26769 100644 (file)
@@ -1810,6 +1810,13 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
       n = neighbour_add (handle, target);
 
     }
+  if (n == NULL)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Could not create neighbour entry for peer `%s'\n",
+                 GNUNET_i2s (target));
+      return NULL;
+    }
 
   /**
    *  Send a request connect message if not connected,
@@ -1821,13 +1828,6 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle
       send_request_connect_message(handle, n);
     }
 
-  if (n == NULL)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Could not create neighbour entry for peer `%s'\n",
-                 GNUNET_i2s (target));
-      return NULL;
-    }
   switch (n->transmit_stage)
     {
     case TS_NEW: