about summary refs log tree commit diff
path: root/nis/nis_getservlist.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
committerUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
commita334319f6530564d22e775935d9c91663623a1b4 (patch)
treeb5877475619e4c938e98757d518bb1e9cbead751 /nis/nis_getservlist.c
parent0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff)
downloadglibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz
glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.xz
glibc-a334319f6530564d22e775935d9c91663623a1b4.zip
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'nis/nis_getservlist.c')
-rw-r--r--nis/nis_getservlist.c57
1 files changed, 12 insertions, 45 deletions
diff --git a/nis/nis_getservlist.c b/nis/nis_getservlist.c
index e57649d526..315960c8e8 100644
--- a/nis/nis_getservlist.c
+++ b/nis/nis_getservlist.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998, 1999, 2000, 2006 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -40,10 +40,7 @@ nis_getservlist (const_nis_name dir)
 	malloc (sizeof (nis_server *) *
 		(NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1));
       if (__builtin_expect (serv == NULL, 0))
-	{
-	  nis_freeresult (res);
-	  return NULL;
-	}
+	return NULL;
 
       for (i = 0; i < NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len;
 	   ++i)
@@ -52,41 +49,13 @@ nis_getservlist (const_nis_name dir)
 	    &NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_val[i];
 	  serv[i] = calloc (1, sizeof (nis_server));
 	  if (__builtin_expect (serv[i] == NULL, 0))
-	    {
-	    free_all:
-	      while (i-- > 0)
-		{
-		  free (serv[i]->pkey.n_bytes);
-		  if (serv[i]->ep.ep_val != NULL)
-		    {
-		      unsigned long int j;
-		      for (j = 0; j < serv[i]->ep.ep_len; ++j)
-			{
-			  free (serv[i]->ep.ep_val[j].proto);
-			  free (serv[i]->ep.ep_val[j].family);
-			  free (serv[i]->ep.ep_val[j].uaddr);
-			}
-		      free (serv[i]->ep.ep_val);
-		    }
-		  free (serv[i]->name);
-		  free (serv[i]);
-		}
-
-	      free (serv);
-
-	      nis_freeresult (res);
-
-	      return NULL;
-	    }
+	    return NULL;
 
 	  if (server->name != NULL)
 	    {
 	      serv[i]->name = strdup (server->name);
 	      if (__builtin_expect (serv[i]->name == NULL, 0))
-		{
-		  ++i;
-		  goto free_all;
-		}
+		return NULL;
 	    }
 
           serv[i]->ep.ep_len = server->ep.ep_len;
@@ -97,10 +66,7 @@ nis_getservlist (const_nis_name dir)
               serv[i]->ep.ep_val =
 		malloc (server->ep.ep_len * sizeof (endpoint));
 	      if (__builtin_expect (serv[i]->ep.ep_val == NULL, 0))
-		{
-		  ++i;
-		  goto free_all;
-		}
+		return NULL;
 
               for (j = 0; j < serv[i]->ep.ep_len; ++j)
                 {
@@ -121,20 +87,20 @@ nis_getservlist (const_nis_name dir)
 		    serv[i]->ep.ep_val[j].proto = NULL;
                 }
             }
-
+          else
+	    serv[i]->ep.ep_val = NULL;
           serv[i]->key_type = server->key_type;
           serv[i]->pkey.n_len = server->pkey.n_len;
           if (server->pkey.n_len > 0)
             {
               serv[i]->pkey.n_bytes = malloc (server->pkey.n_len);
               if (__builtin_expect (serv[i]->pkey.n_bytes == NULL, 0))
-		{
-		  ++i;
-		  goto free_all;
-		}
+                return NULL;
               memcpy (serv[i]->pkey.n_bytes, server->pkey.n_bytes,
                       server->pkey.n_len);
             }
+          else
+            serv[i]->pkey.n_bytes = NULL;
         }
       serv[i] = NULL;
     }
@@ -145,7 +111,8 @@ nis_getservlist (const_nis_name dir)
 	serv[0] = NULL;
     }
 
-  nis_freeresult (res);
+  if (res != NULL)
+    nis_freeresult (res);
 
   return serv;
 }