Skip to content

Commit

Permalink
update(libsinsp): empty transformer storage before filling len()
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <[email protected]>
  • Loading branch information
LucaGuerra authored and poiana committed Oct 31, 2024
1 parent ecf46c0 commit 5f32757
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions userspace/libsinsp/sinsp_filter_transformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ bool sinsp_filter_transformer::transform_values(std::vector<extract_value_t>& 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<uint64_t>(vec.size());
auto stored_val = store_scalar(len);
Expand All @@ -227,8 +228,9 @@ bool sinsp_filter_transformer::transform_values(std::vector<extract_value_t>& 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
Expand Down

0 comments on commit 5f32757

Please sign in to comment.