summary refs log tree commit diff
path: root/nis
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-05-05 06:01:26 +0000
committerUlrich Drepper <drepper@redhat.com>2006-05-05 06:01:26 +0000
commitf2d5cf5005abf48aeaf4e7e8093aa49f32c76756 (patch)
tree8657a5e96c33edd8d59614a4f16719b668efcec8 /nis
parent3e4370cf2b647d5c1ff8579283878f59875d3645 (diff)
downloadglibc-f2d5cf5005abf48aeaf4e7e8093aa49f32c76756.tar.gz
glibc-f2d5cf5005abf48aeaf4e7e8093aa49f32c76756.tar.xz
glibc-f2d5cf5005abf48aeaf4e7e8093aa49f32c76756.zip
* nis/nis_table.c (nis_list): Avoid clearing res twice before
	filling it for the first time.
Diffstat (limited to 'nis')
-rw-r--r--nis/nis_table.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/nis/nis_table.c b/nis/nis_table.c
index 1a7bf094f0..49a630312a 100644
--- a/nis/nis_table.c
+++ b/nis/nis_table.c
@@ -167,7 +167,7 @@ nis_list (const_nis_name name, unsigned int flags,
 			   const void *userdata),
 	  const void *userdata)
 {
-  nis_result *res = calloc (1, sizeof (nis_result));
+  nis_result *res = malloc (sizeof (nis_result));
   ib_request *ibreq;
   int status;
   enum clnt_stat clnt_status;
@@ -180,20 +180,24 @@ nis_list (const_nis_name name, unsigned int flags,
   char *tableptr;
   char *tablepath = NULL;
   int first_try = 0; /* Do we try the old binding at first ? */
+  int errcode;
 
   if (res == NULL)
     return NULL;
 
   if (name == NULL)
     {
+      errcode = NIS_BADNAME;
+    err_out:
+      memset (res, '\0', sizeof (nis_result));
       NIS_RES_STATUS (res) = NIS_BADNAME;
       return res;
     }
 
   if ((ibreq = __create_ib_request (name, flags)) == NULL)
     {
-      NIS_RES_STATUS (res) = NIS_BADNAME;
-      return res;
+      errcode = NIS_BADNAME;
+      goto err_out;
     }
 
   if ((flags & EXPAND_NAME)
@@ -205,16 +209,16 @@ nis_list (const_nis_name name, unsigned int flags,
       if (names == NULL)
 	{
 	  nis_free_request (ibreq);
-	  NIS_RES_STATUS (res) = NIS_BADNAME;
-	  return res;
+	  errcode = NIS_BADNAME;
+	  goto err_out;
 	}
       ibreq->ibr_name = strdup (names[name_nr]);
       if (ibreq->ibr_name == NULL)
 	{
 	  nis_freenames (names);
 	  nis_free_request (ibreq);
-	  NIS_RES_STATUS (res) = NIS_NOMEMORY;
-	  return res;
+	  errcode = NIS_NOMEMORY;
+	  goto err_out;
 	}
     }
   else