about summary refs log tree commit diff
path: root/nis/nis_file.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-05-05 11:04:34 +0000
committerUlrich Drepper <drepper@redhat.com>1999-05-05 11:04:34 +0000
commit3d8fa13a1474077255e79b7550b279239bfb083c (patch)
treecc33b7c50a3e82507e4a58e990ec8905f9bfce17 /nis/nis_file.c
parentb5a9efcd9342681200280ef9f764b744d62b62ce (diff)
downloadglibc-3d8fa13a1474077255e79b7550b279239bfb083c.tar.gz
glibc-3d8fa13a1474077255e79b7550b279239bfb083c.tar.xz
glibc-3d8fa13a1474077255e79b7550b279239bfb083c.zip
Update.
1999-05-05  Thorsten Kukuk  <kukuk@suse.de>

	* nis/nis_file.c (readColdStartFile): Allocate memory only after
	the file is opened successfully.

	* nis/nis_table.c: Fix some memory leaks.
Diffstat (limited to 'nis/nis_file.c')
-rw-r--r--nis/nis_file.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/nis/nis_file.c b/nis/nis_file.c
index 0ffac68fe2..8d652c30e5 100644
--- a/nis/nis_file.c
+++ b/nis/nis_file.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.
 
@@ -30,27 +30,31 @@ readColdStartFile (void)
 {
   XDR xdrs;
   FILE *in;
-  bool_t status;
-  directory_obj *obj = calloc (1, sizeof (directory_obj));
-
-  if (obj == NULL)
-    return NULL;
+  bool_t status = TRUE;
+  directory_obj *obj;
 
   in = fopen (cold_start_file, "rb");
   if (in == NULL)
     return NULL;
-  xdrstdio_create (&xdrs, in, XDR_DECODE);
-  status = _xdr_directory_obj (&xdrs, obj);
-  xdr_destroy (&xdrs);
-  fclose (in);
 
-  if (status)
-    return obj;
-  else
+  obj = calloc (1, sizeof (directory_obj));
+
+  if (obj != NULL)
     {
-      nis_free_directory (obj);
-      return NULL;
+      xdrstdio_create (&xdrs, in, XDR_DECODE);
+      status = _xdr_directory_obj (&xdrs, obj);
+      xdr_destroy (&xdrs);
+
+      if (!status)
+	{
+	  nis_free_directory (obj);
+	  obj = NULL;
+	}
     }
+
+  fclose (in);
+
+  return obj;
 }
 
 bool_t