aboutsummaryrefslogtreecommitdiff
path: root/nis/nis_addmember.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_addmember.c
parent1483b7537883c00276b91f8c35496594edd5b073 (diff)
downloadglibc-843ede44f78a91de84613f7581efadb13dbc6d25.tar
glibc-843ede44f78a91de84613f7581efadb13dbc6d25.tar.gz
glibc-843ede44f78a91de84613f7581efadb13dbc6d25.tar.bz2
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_addmember.c')
-rw-r--r--nis/nis_addmember.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/nis/nis_addmember.c b/nis/nis_addmember.c
index 2a31903572..3f1c2b3d99 100644
--- a/nis/nis_addmember.c
+++ b/nis/nis_addmember.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.
@@ -50,13 +50,25 @@ nis_addmember (const_nis_name member, const_nis_name group)
}
if ((NIS_RES_NUMOBJ (res) != 1) ||
(__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ))
- return NIS_INVALIDOBJ;
+ {
+ nis_freeresult (res);
+ return NIS_INVALIDOBJ;
+ }
NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val
= realloc (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val,
(NIS_RES_OBJECT(res)->GR_data.gr_members.gr_members_len + 1)
* sizeof (char *));
+ if (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val == NULL)
+ goto nomem_out;
NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len] = strdup (member);
+ if (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len] == NULL)
+ {
+ free (NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val);
+ nomem_out:
+ nis_freeresult (res);
+ return NIS_NOMEMORY;
+ }
++NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len;
cp = stpcpy (buf, NIS_RES_OBJECT(res)->zo_name);