From 58bfa94d81062fe08d1ff1fc14b4fcd4ee3d7080 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Wed, 30 Jul 2008 18:38:29 -0400 Subject: backend_free_gathered_data() - double-check that arrays aren't NULL before indexing then backend_gather_data() - in the event of a parsing error, actually return zero as the length of the arrays we'd be populating - correctly NULL terminate the list of results we hand back --- src/back-nis.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/back-nis.c') diff --git a/src/back-nis.c b/src/back-nis.c index 07fe0cd..915b5cf 100644 --- a/src/back-nis.c +++ b/src/back-nis.c @@ -157,15 +157,19 @@ backend_free_gathered_data(char **all, unsigned int *all_lengths, unsigned int i; free(all); free(all_lengths); - for (i = 0; i < n_singles; i++) { - format_free_data(singles[i]); + if (singles != NULL) { + for (i = 0; i < n_singles; i++) { + format_free_data(singles[i]); + } } free(singles); - for (i = 0; i < n_groups; i++) { - format_free_data_set(groups[i], group_lengths[i]); + if (groups != NULL) { + for (i = 0; i < n_groups; i++) { + format_free_data_set(groups[i], group_lengths[i]); + } } - free(group_lengths); free(groups); + free(group_lengths); } static char ** backend_gather_data(struct plugin_state *state, Slapi_Entry *e, @@ -244,7 +248,10 @@ backend_gather_data(struct plugin_state *state, Slapi_Entry *e, free(groups); free(group_lengths); *ret_singles = NULL; + *ret_n_singles = 0; *ret_groups = NULL; + *ret_group_lengths = NULL; + *ret_n_groups = 0; *ret_lengths = NULL; return NULL; } @@ -286,6 +293,7 @@ backend_gather_data(struct plugin_state *state, Slapi_Entry *e, } } } + ret[k] = NULL; *ret_lengths = lengths; *ret_n_singles = n_singles; *ret_singles = singles; -- cgit