# HG changeset patch # User Mike Becker # Date 1570094148 -7200 # Node ID 0f5732f0dc009a8830535ec19479fdb54ab714e7 # Parent 77efe51c6c9ab5e37151281a35f36c08d2f54bc5 fixes two bugs: clone to uninitialized array and missing return in ucx_array_ensurecap() diff -r 77efe51c6c9a -r 0f5732f0dc00 src/array.c --- a/src/array.c Thu Oct 03 10:55:39 2019 +0200 +++ b/src/array.c Thu Oct 03 11:15:48 2019 +0200 @@ -66,6 +66,7 @@ if (ucx_array_reserve(array, required_capacity)) { return 1; } + return 0; } int ucx_array_util_set_a(UcxAllocator* alloc, void** array, size_t* capacity, diff -r 77efe51c6c9a -r 0f5732f0dc00 src/ucx/array.h --- a/src/ucx/array.h Thu Oct 03 10:55:39 2019 +0200 +++ b/src/ucx/array.h Thu Oct 03 11:15:48 2019 +0200 @@ -188,6 +188,8 @@ * If the destination capacity is insufficient, an automatic reallocation is * attempted. * + * Note: if the destination array is uninitialized, the behavior is undefined. + * * @param dest the array to copy to * @param src the array to copy from * @return zero on success, non-zero on reallocation failure. diff -r 77efe51c6c9a -r 0f5732f0dc00 test/array_tests.c --- a/test/array_tests.c Thu Oct 03 10:55:39 2019 +0200 +++ b/test/array_tests.c Thu Oct 03 11:15:48 2019 +0200 @@ -467,6 +467,7 @@ UcxArray array; UcxArray copy; ucx_array_init(&array, 16, sizeof(int)); + ucx_array_init(©, 4, 2*sizeof(double)); int *elems; array.size = 5;