about summary refs log tree commit diff
path: root/nis/nis_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'nis/nis_file.c')
-rw-r--r--nis/nis_file.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/nis/nis_file.c b/nis/nis_file.c
index 94fa4eb865..0ffac68fe2 100644
--- a/nis/nis_file.c
+++ b/nis/nis_file.c
@@ -31,18 +31,26 @@ readColdStartFile (void)
   XDR xdrs;
   FILE *in;
   bool_t status;
-  directory_obj obj;
+  directory_obj *obj = calloc (1, sizeof (directory_obj));
+
+  if (obj == NULL)
+    return NULL;
 
   in = fopen (cold_start_file, "rb");
   if (in == NULL)
     return NULL;
-  memset (&obj, '\0', sizeof (obj));
   xdrstdio_create (&xdrs, in, XDR_DECODE);
-  status = _xdr_directory_obj (&xdrs, &obj);
+  status = _xdr_directory_obj (&xdrs, obj);
   xdr_destroy (&xdrs);
   fclose (in);
 
-  return status ? nis_clone_directory (&obj, NULL) : NULL;
+  if (status)
+    return obj;
+  else
+    {
+      nis_free_directory (obj);
+      return NULL;
+    }
 }
 
 bool_t
@@ -70,19 +78,27 @@ nis_read_obj (const char *name)
   XDR xdrs;
   FILE *in;
   bool_t status;
-  nis_object obj;
+  nis_object *obj = calloc (1, sizeof (nis_object));
+
+  if (obj == NULL)
+    return NULL;
 
   in = fopen (name, "rb");
   if (in == NULL)
     return NULL;
 
-  memset (&obj, '\0', sizeof (obj));
   xdrstdio_create (&xdrs, in, XDR_DECODE);
-  status =_xdr_nis_object (&xdrs, &obj);
+  status =_xdr_nis_object (&xdrs, obj);
   xdr_destroy (&xdrs);
   fclose (in);
 
-  return status ? nis_clone_object (&obj, NULL) : NULL;
+  if (status)
+    return obj;
+  else
+    {
+      nis_free_object (obj);
+      return NULL;
+    }
 }
 
 bool_t