2005-04-29 Ulrich Drepper <drepper@redhat.com>

[BZ #1093]
	* nis/nis_table.c: Fix realloc handling.
	* nis/nis_removemember.c: Likewise.
This commit is contained in:
Roland McGrath 2005-07-18 02:48:38 +00:00
parent 9e416865e4
commit 6bdd7b167e
2 changed files with 10 additions and 5 deletions

View File

@ -92,9 +92,13 @@ nis_removemember (const_nis_name member, const_nis_name group)
/* This realloc() call always decreases the size. This cannot
fail. We still have the test but do not recover memory
(i.e., we overwrite the input pointer). */
newmem = realloc (newmem, k * sizeof (char*));
if (newmem == NULL)
return NIS_NOMEMORY;
nis_name *newp = realloc (newmem, k * sizeof (char*));
if (newp == NULL)
{
free (newmem);
return NIS_NOMEMORY;
}
newmem = newp;
NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val = newmem;
NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len = k;

View File

@ -94,9 +94,10 @@ __create_ib_request (const_nis_name name, unsigned int flags)
if ((search_len + 1) >= size)
{
size += 1;
search_val = realloc (search_val, size * sizeof (nis_attr));
if (search_val == NULL)
nis_attr *newp = realloc (search_val, size * sizeof (nis_attr));
if (newp == NULL)
goto free_null;
search_val = newp;
}
search_val[search_len].zattr_ndx = strdup (key);
if ((search_val[search_len].zattr_ndx) == NULL)