about summary refs log tree commit diff
path: root/nis/nis_getservlist.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-05-14 23:38:21 +0000
committerUlrich Drepper <drepper@redhat.com>1999-05-14 23:38:21 +0000
commit843ede44f78a91de84613f7581efadb13dbc6d25 (patch)
treea0b7d96433062ff25d96994ba9aec288d4629f91 /nis/nis_getservlist.c
parent1483b7537883c00276b91f8c35496594edd5b073 (diff)
downloadglibc-843ede44f78a91de84613f7581efadb13dbc6d25.tar.gz
glibc-843ede44f78a91de84613f7581efadb13dbc6d25.tar.xz
glibc-843ede44f78a91de84613f7581efadb13dbc6d25.zip
Update.
1999-05-14  Ulrich Drepper  <drepper@cygnus.com>

	* nis/nis_getservlist.c (nis_getservlist): Use malloc instead of
	calloc.

	* nis/nis_checkpoint.c (nis_checkpoint): Fix memory leaks.
	* nis/nis_addmember.c (nis_addmember): Fix memory leak.  Test
	memory allocation results.
Diffstat (limited to 'nis/nis_getservlist.c')
-rw-r--r--nis/nis_getservlist.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/nis/nis_getservlist.c b/nis/nis_getservlist.c
index f88c156f89..a6f43f880d 100644
--- a/nis/nis_getservlist.c
+++ b/nis/nis_getservlist.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -37,7 +37,7 @@ nis_getservlist (const_nis_name dir)
       nis_server *server;
 
       serv =
-	calloc (1, sizeof (nis_server *) *
+	malloc (sizeof (nis_server *) *
 		(NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1));
       if (serv == NULL)
 	return NULL;
@@ -53,10 +53,13 @@ nis_getservlist (const_nis_name dir)
           serv[i]->ep.ep_len = server->ep.ep_len;
           if (serv[i]->ep.ep_len > 0)
             {
-              unsigned long j;
+              unsigned long int j;
 
               serv[i]->ep.ep_val =
 		malloc (server->ep.ep_len * sizeof (endpoint));
+	      if (serv[i]->ep.ep_val == NULL)
+		return NULL;
+
               for (j = 0; j < serv[i]->ep.ep_len; ++j)
                 {
                   if (server->ep.ep_val[j].uaddr)
@@ -92,6 +95,9 @@ nis_getservlist (const_nis_name dir)
           else
             serv[i]->pkey.n_bytes = NULL;
         }
+      serv[i] = NULL;
+
+      nis_freeresult (res);
     }
   else
     {