diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-09-08 17:41:58 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-09-08 17:41:58 -0400 |
| commit | 49dcee1148fe2eed4023835e71c847143d24cf25 (patch) | |
| tree | adb48eceac5ceaed25e6891c9f5994809a687873 /src | |
| parent | 0949239ce22537cd28ff5feed3e2ca9bd90a4a5c (diff) | |
| download | slapi-nis-49dcee1148fe2eed4023835e71c847143d24cf25.tar.gz slapi-nis-49dcee1148fe2eed4023835e71c847143d24cf25.tar.xz slapi-nis-49dcee1148fe2eed4023835e71c847143d24cf25.zip | |
- be a little more careful when freeing lists
- free the list of entries we're visiting, in case we're poorly
specified for some reason
- stop chasing links if we run out of entries before we run out of link
attributes to follow
Diffstat (limited to 'src')
| -rw-r--r-- | src/format.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/format.c b/src/format.c index 26abcd6..8db5d0a 100644 --- a/src/format.c +++ b/src/format.c @@ -106,10 +106,12 @@ static void format_free_sdn_list(struct slapi_dn **list) { unsigned int i; - for (i = 0; (list != NULL) && (list[i] != NULL); i++) { - slapi_sdn_free(&(list[i])); + if (list != NULL) { + for (i = 0; list[i] != NULL; i++) { + slapi_sdn_free(&(list[i])); + } + free(list); } - free(list); } static struct slapi_dn ** @@ -164,19 +166,23 @@ format_add_sdn_list(struct slapi_dn ***list, const char *dn) void format_free_ref_attr_list(struct format_ref_attr_list **list) { + Slapi_DN **sdn_list; unsigned int i; int j; - for (i = 0; (list != NULL) && (list[i] != NULL); i++) { - for (j = 0; j < list[i]->n_links; j++) { - free(list[i]->links[j].attribute); - format_free_sdn_list(list[i]->links[j].base_sdn_list); + if (list != NULL) { + for (i = 0; list[i] != NULL; i++) { + for (j = 0; j < list[i]->n_links; j++) { + free(list[i]->links[j].attribute); + sdn_list = list[i]->links[j].base_sdn_list; + format_free_sdn_list(sdn_list); + } + free(list[i]->links); + free(list[i]->set); + free(list[i]->group); + free(list[i]); } - free(list[i]->links); - free(list[i]->set); - free(list[i]->group); - free(list[i]); + free(list); } - free(list); } struct format_ref_attr_list ** @@ -1044,7 +1050,7 @@ format_derefx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, * to build a list of entries to visit the next time. For the last * link, pull the values out and prep them to be returned to our * caller. */ - for (i = 0; i < list->n_links; i++) { + for (i = 0; (these != NULL) && (i < list->n_links); i++) { next = NULL; attrs[0] = list->links[i].attribute; attrs[1] = NULL; @@ -1121,6 +1127,7 @@ format_derefx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Clean up and return any values we found. */ + format_free_sdn_list(these); format_free_parsed_args(argv); if (choices != NULL) { format_add_choice(outbuf_choices, outbuf, choices); |
