]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: array - additional compile-time checks to array_append
authorPhil Carmody <phil@dovecot.fi>
Tue, 25 Nov 2014 01:48:42 +0000 (03:48 +0200)
committerPhil Carmody <phil@dovecot.fi>
Tue, 25 Nov 2014 01:48:42 +0000 (03:48 +0200)
The new two-array helper macro works in this context too.

Note: array_copy doesn't have any protection currently, it isn't
obvious how to wrap that with some safety without breaking interfaces.
It only seems to have one internal user, lib/aqueue.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
src/lib/array.h

index 261fef0b8e4f2eceb07a7154f0aa3e12298a9c64..166cf5876d14387bc225f8077f7ebe4bf06b961d 100644 (file)
@@ -164,7 +164,8 @@ array_append_array_i(struct array *dest_array, const struct array *src_array)
        buffer_append_buf(dest_array->buffer, src_array->buffer, 0, (size_t)-1);
 }
 #define array_append_array(dest_array, src_array) \
-       array_append_array_i(&(dest_array)->arr, &(src_array)->arr)
+       array_append_array_i(&(dest_array)->arr + ARRAY_TYPES_CHECK(dest_array, src_array), \
+                            &(src_array)->arr)
 
 static inline void
 array_insert_i(struct array *array, unsigned int idx,