aboutsummaryrefslogtreecommitdiff
path: root/nis/nis_getservlist.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-05-16 10:14:25 +0000
committerUlrich Drepper <drepper@redhat.com>1999-05-16 10:14:25 +0000
commit32abdb710c9335481da780eab5ad790318d2fadf (patch)
tree70c94809f5ec43a895c614a445a32f4d18d925c5 /nis/nis_getservlist.c
parent7d853c902b9f79a32c8c1921b16107648c15f0e3 (diff)
downloadglibc-32abdb710c9335481da780eab5ad790318d2fadf.tar
glibc-32abdb710c9335481da780eab5ad790318d2fadf.tar.gz
glibc-32abdb710c9335481da780eab5ad790318d2fadf.tar.bz2
glibc-32abdb710c9335481da780eab5ad790318d2fadf.zip
Update.
1999-05-16 Thorsten Kukuk <kukuk@suse.de> * sunrpc/etc.rpc: Add portmapper, rstat_svc and pcnfs. * sunrpc/key_call.c: Fix memory leak, close file handle. * nis/nis_creategroup.c: Use malloc instead of calloc, set ctime and mtime. * nis/nis_subr.c: Check for realloc result. * nis/nis_file.c: Fix memory leak. * nis/nis_table.c: Pretty print. * nis/nis_getservlist.c: Likewise. * nis/nis_ismember.c: Likewise. * nis/nis_lookup.c: Likewise. * nis/nis_ping.c: Likewise. * nis/nis_removemember.c: Likewise. * nis/nis_util.c: Likewise, check calloc result.
Diffstat (limited to 'nis/nis_getservlist.c')
-rw-r--r--nis/nis_getservlist.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/nis/nis_getservlist.c b/nis/nis_getservlist.c
index a6f43f880d..5d93f38d9a 100644
--- a/nis/nis_getservlist.c
+++ b/nis/nis_getservlist.c
@@ -31,7 +31,7 @@ nis_getservlist (const_nis_name dir)
res = nis_lookup (dir, FOLLOW_LINKS);
- if (NIS_RES_STATUS (res) == NIS_SUCCESS)
+ if (res != NULL && NIS_RES_STATUS (res) == NIS_SUCCESS)
{
unsigned long i;
nis_server *server;
@@ -41,6 +41,7 @@ nis_getservlist (const_nis_name dir)
(NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1));
if (serv == NULL)
return NULL;
+
for (i = 0; i < NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len;
++i)
{
@@ -48,7 +49,11 @@ 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 (server->name != NULL)
- serv[i]->name = strdup (server->name);
+ {
+ serv[i]->name = strdup (server->name);
+ if (serv[i]->name == NULL)
+ return NULL;
+ }
serv[i]->ep.ep_len = server->ep.ep_len;
if (serv[i]->ep.ep_len > 0)
@@ -96,8 +101,6 @@ nis_getservlist (const_nis_name dir)
serv[i]->pkey.n_bytes = NULL;
}
serv[i] = NULL;
-
- nis_freeresult (res);
}
else
{
@@ -105,6 +108,10 @@ nis_getservlist (const_nis_name dir)
if (serv != NULL)
serv[0] = NULL;
}
+
+ if (res != NULL)
+ nis_freeresult (res);
+
return serv;
}