From 5f327574787ada8fc635399de77073ee20bab7ca Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Thu, 31 Oct 2024 10:13:20 +0000 Subject: [PATCH] update(libsinsp): empty transformer storage before filling len() Signed-off-by: Luca Guerra --- userspace/libsinsp/sinsp_filter_transformer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/userspace/libsinsp/sinsp_filter_transformer.cpp b/userspace/libsinsp/sinsp_filter_transformer.cpp index 9d04cf7770..158d39ce86 100644 --- a/userspace/libsinsp/sinsp_filter_transformer.cpp +++ b/userspace/libsinsp/sinsp_filter_transformer.cpp @@ -203,6 +203,7 @@ bool sinsp_filter_transformer::transform_values(std::vector& ve } case FTR_LEN: { assert((void("len() type must be PT_UINT64"), t == PT_UINT64)); + m_storage_values.clear(); if(is_list) { uint64_t len = static_cast(vec.size()); auto stored_val = store_scalar(len); @@ -227,8 +228,9 @@ bool sinsp_filter_transformer::transform_values(std::vector& ve } if(vec.size() == 0) { - // nothing to do - return true; + // should never happen since there is no way to + // call len() with no arguments + return false; } // we are assuming that if this is not a list then it's a single element