Mercurial > dovecot > core-2.2
changeset 4602:444edc8abef9 HEAD
Don't allow giving NULL parameter to array_get() or array_get_modifiable().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 16 Sep 2006 16:40:17 +0300 |
parents | 664011f3b1fb |
children | 20e2bc758c24 |
files | src/lib-index/mail-index-sync.c src/lib-index/mail-index-transaction.c src/lib-storage/index/index-mail.c src/lib/array.h src/lib/module-dir.c src/plugins/trash/trash-plugin.c |
diffstat | 6 files changed, 10 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync.c Sat Sep 16 16:31:14 2006 +0300 +++ b/src/lib-index/mail-index-sync.c Sat Sep 16 16:40:17 2006 +0300 @@ -234,7 +234,7 @@ } keyword_updates = keyword_count == 0 ? NULL : - array_get(&ctx->trans->keyword_updates, NULL); + array_idx(&ctx->trans->keyword_updates, 0); for (i = 0; i < keyword_count; i++) { if (array_is_created(&keyword_updates[i].add_seq)) { synclist = array_append_space(&ctx->sync_list);
--- a/src/lib-index/mail-index-transaction.c Sat Sep 16 16:31:14 2006 +0300 +++ b/src/lib-index/mail-index-transaction.c Sat Sep 16 16:40:17 2006 +0300 @@ -852,7 +852,7 @@ k->index = t->view->index; k->count = count; - memcpy(k->idx, array_get(keyword_indexes, NULL), + memcpy(k->idx, array_idx(keyword_indexes, 0), count * sizeof(k->idx[0])); return k; }
--- a/src/lib-storage/index/index-mail.c Sat Sep 16 16:31:14 2006 +0300 +++ b/src/lib-storage/index/index-mail.c Sat Sep 16 16:40:17 2006 +0300 @@ -144,7 +144,7 @@ unsigned int i, count, names_count; if (array_is_created(&data->keywords)) - return array_get(&data->keywords, NULL); + return array_idx(&data->keywords, 0); t_push(); t_array_init(&keyword_indexes_arr, 128); @@ -175,7 +175,7 @@ (void)array_append_space(&data->keywords); t_pop(); - return array_get(&data->keywords, NULL); + return array_idx(&data->keywords, 0); } const struct message_part *index_mail_get_parts(struct mail *_mail)
--- a/src/lib/array.h Sat Sep 16 16:31:14 2006 +0300 +++ b/src/lib/array.h Sat Sep 16 16:40:17 2006 +0300 @@ -146,8 +146,7 @@ static inline const void * _array_get(const struct array *array, unsigned int *count_r) { - if (count_r != NULL) - *count_r = array->buffer->used / array->element_size; + *count_r = array->buffer->used / array->element_size; return array->buffer->data; } #define array_get(array, count) \ @@ -170,8 +169,7 @@ static inline void * _array_get_modifiable(struct array *array, unsigned int *count_r) { - if (count_r != NULL) - *count_r = array->buffer->used / array->element_size; + *count_r = array->buffer->used / array->element_size; return buffer_get_modifiable_data(array->buffer, NULL); } #define array_get_modifiable(array, count) \
--- a/src/lib/module-dir.c Sat Sep 16 16:31:14 2006 +0300 +++ b/src/lib/module-dir.c Sat Sep 16 16:40:17 2006 +0300 @@ -195,8 +195,7 @@ array_append(&names, &name, 1); } - names_p = array_get_modifiable(&names, NULL); - count = array_count(&names); + names_p = array_get_modifiable(&names, &count); qsort(names_p, count, sizeof(const char *), module_name_cmp); t_push();
--- a/src/plugins/trash/trash-plugin.c Sat Sep 16 16:31:14 2006 +0300 +++ b/src/plugins/trash/trash-plugin.c Sat Sep 16 16:40:17 2006 +0300 @@ -186,6 +186,7 @@ struct istream *input; const char *line, *name; struct trash_mailbox *trash; + unsigned int count; int fd; fd = open(path, O_RDONLY); @@ -211,9 +212,8 @@ i_stream_destroy(&input); (void)close(fd); - qsort(array_get_modifiable(&trash_boxes, NULL), - array_count(&trash_boxes), sizeof(struct trash_mailbox), - trash_mailbox_priority_cmp); + trash = array_get_modifiable(&trash_boxes, &count); + qsort(trash, count, sizeof(*trash), trash_mailbox_priority_cmp); return 0; }