From 9a2369841d1336cd6db75475d4ab8c5b0a708b99 Mon Sep 17 00:00:00 2001 From: Ezra Chung Date: Thu, 13 Nov 2025 12:37:10 -0600 Subject: [PATCH] Ensure dst_vec is initialized after init_copy() --- src/common/src/mlib/vec.th | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/src/mlib/vec.th b/src/common/src/mlib/vec.th index 453b80c9fbe..65f243a51f4 100644 --- a/src/common/src/mlib/vec.th +++ b/src/common/src/mlib/vec.th @@ -396,6 +396,8 @@ fn(init_copy(VecName *dst_vec, VecName const *src_vec)) mlib_noexcept if (!fn(reserve(&tmp, src_vec->size))) { // We failed to reserve capacity in the new vector fn(destroy(&tmp)); + // Always leave `dst_vec` in an initialized state. + *dst_vec = (VecName){NULL, 0, 0}; return false; } // Copy everything into the destination element-by-element @@ -412,6 +414,8 @@ fn(init_copy(VecName *dst_vec, VecName const *src_vec)) mlib_noexcept if (!VecCopyElement((out_iter), (in_iter))) { // Failed copying here. Undo everything by destroying the temporary fn(destroy(&tmp)); + // Always leave `dst_vec` in an initialized state. + *dst_vec = (VecName){NULL, 0, 0}; return false; } // Update the size of the temporary vec to record that it is holding the new