From 36ffe2970ffe90c1ddf2fcb9a7cedff7bd7b7f8c Mon Sep 17 00:00:00 2001 From: erer1243 <1377477+erer1243@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:24:42 -0500 Subject: [PATCH] Valgrind fix --- crates/swss-common/src/types.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/swss-common/src/types.rs b/crates/swss-common/src/types.rs index 0ba4c8f..657b094 100644 --- a/crates/swss-common/src/types.rs +++ b/crates/swss-common/src/types.rs @@ -202,12 +202,14 @@ pub(crate) unsafe fn take_key_op_field_values_array(kfvs: SWSSKeyOpFieldValuesAr /// Takes ownership of an `SWSSStringArray` and turns it into a native representation. pub(crate) unsafe fn take_string_array(arr: SWSSStringArray) -> Vec { - if !arr.data.is_null() { + let out = if !arr.data.is_null() { let entries = slice::from_raw_parts(arr.data, arr.len as usize); Vec::from_iter(entries.iter().map(|&s| take_cstr(s))) } else { Vec::new() - } + }; + SWSSStringArray_free(arr); + out } pub(crate) fn make_field_value_array(fvs: I) -> (SWSSFieldValueArray, KeepAlive)