Skip to content

Commit

Permalink
* nis/nis_table.c (nis_list): Avoid clearing res twice before
Browse files Browse the repository at this point in the history
	filling it for the first time.
  • Loading branch information
Ulrich Drepper committed May 5, 2006
1 parent 3e4370c commit f2d5cf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2006-05-04 Ulrich Drepper <drepper@redhat.com>

* nis/nis_table.c (nis_list): Avoid clearing res twice before
filling it for the first time.

* nis/nis_table.c (get_tablepath): Renamed from __get_tablepath.
Adjust all callers.
Free res object content before returning.
Expand Down
18 changes: 11 additions & 7 deletions nis/nis_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ nis_list (const_nis_name name, unsigned int flags,
const void *userdata),
const void *userdata)
{
nis_result *res = calloc (1, sizeof (nis_result));
nis_result *res = malloc (sizeof (nis_result));
ib_request *ibreq;
int status;
enum clnt_stat clnt_status;
Expand All @@ -180,20 +180,24 @@ nis_list (const_nis_name name, unsigned int flags,
char *tableptr;
char *tablepath = NULL;
int first_try = 0; /* Do we try the old binding at first ? */
int errcode;

if (res == NULL)
return NULL;

if (name == NULL)
{
errcode = NIS_BADNAME;
err_out:
memset (res, '\0', sizeof (nis_result));
NIS_RES_STATUS (res) = NIS_BADNAME;
return res;
}

if ((ibreq = __create_ib_request (name, flags)) == NULL)
{
NIS_RES_STATUS (res) = NIS_BADNAME;
return res;
errcode = NIS_BADNAME;
goto err_out;
}

if ((flags & EXPAND_NAME)
Expand All @@ -205,16 +209,16 @@ nis_list (const_nis_name name, unsigned int flags,
if (names == NULL)
{
nis_free_request (ibreq);
NIS_RES_STATUS (res) = NIS_BADNAME;
return res;
errcode = NIS_BADNAME;
goto err_out;
}
ibreq->ibr_name = strdup (names[name_nr]);
if (ibreq->ibr_name == NULL)
{
nis_freenames (names);
nis_free_request (ibreq);
NIS_RES_STATUS (res) = NIS_NOMEMORY;
return res;
errcode = NIS_NOMEMORY;
goto err_out;
}
}
else
Expand Down

0 comments on commit f2d5cf5

Please sign in to comment.