fixing memory leak
authorChristian Grothoff <christian@grothoff.org>
Tue, 1 Jun 2010 21:05:24 +0000 (21:05 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 1 Jun 2010 21:05:24 +0000 (21:05 +0000)
src/transport/test_plugin_transport_http.c

index 9354cad7070d7c5ae947d0dc43077d513e83fa58..b28750443941d15c65c6db0945316607d0b7e7d0 100644 (file)
@@ -609,26 +609,25 @@ notify_address (void *cls,
                 uint16_t addrlen,
                 struct GNUNET_TIME_Relative expires)
 {
-  char * address = NULL;
+  char address[INET6_ADDRSTRLEN];
   unsigned int port;
   struct Plugin_Address * pl_addr;
   struct Plugin_Address * cur;
 
   if (addrlen == (sizeof (struct IPv4HttpAddress)))
-  {
-    address = GNUNET_malloc (INET_ADDRSTRLEN);
-    inet_ntop(AF_INET, (struct in_addr *) addr,address,INET_ADDRSTRLEN);
-    port = ntohs(((struct IPv4HttpAddress *) addr)->u_port);
-  }
-
+    {
+      inet_ntop(AF_INET, (struct in_addr *) addr,address,INET_ADDRSTRLEN);
+      port = ntohs(((struct IPv4HttpAddress *) addr)->u_port);
+    }
   if (addrlen == (sizeof (struct IPv6HttpAddress)))
-  {
-    address = GNUNET_malloc (INET6_ADDRSTRLEN);
-    inet_ntop(AF_INET6, (struct in6_addr *) addr,address,INET6_ADDRSTRLEN);
-    port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port);
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Transport plugin notification for address: `%s':%u\n"),address,port);
-
+    {
+      inet_ntop(AF_INET6, (struct in6_addr *) addr,address,INET6_ADDRSTRLEN);
+      port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port);
+    }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             _("Transport plugin notification for address: `%s':%u\n"),
+             address,
+             port);
   pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address) );
   pl_addr->addrlen = addrlen;
   pl_addr->addr = GNUNET_malloc(addrlen);
@@ -636,19 +635,18 @@ notify_address (void *cls,
   pl_addr->next = NULL;
 
   if ( NULL == addr_head)
-  {
-    addr_head = pl_addr;
-  }
+    {
+      addr_head = pl_addr;
+    }
   else
-  {
-    cur = addr_head;
-    while (NULL != cur->next)
-      {
-        cur = cur->next;
-      }
-    cur->next = pl_addr;
-  }
-
+    {
+      cur = addr_head;
+      while (NULL != cur->next)
+       {
+         cur = cur->next;
+       }
+      cur->next = pl_addr;
+    }
   fail_notify_address_count++;
   fail_notify_address = GNUNET_NO;
 }