From daae62231a8aa82357c7877d28dfebff475a6059 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Tue, 23 Apr 2024 13:29:35 -0400 Subject: [PATCH] translate.cxx: Fix out-of-bounds vector access The following error was found by building stap with -D_GLIBCXX_DEBUG and -D_GLIBCXX_DEBUG_PEDANTIC: /usr/include/c++/13/debug/vector:442: In function: std::debug::vector<_Tp, _Allocator>::reference std::debug::vector<_Tp, _Allocator>::operator[](size_type) [with _Tp = bool; _Allocator = std::allocator; reference = std::vector >::reference; size_type = long unsigned int] Error: attempt to subscript container with out-of-bounds index 1, but container only holds 1 elements. Objects involved in the operation: sequence "this" @ 0x7fffffff8e70 { type = std::debug::vector >; } This is caused by an incorrectly sized vector in c_unparser::visit_functioncall. Fix this by ensuring that the vector cp_args has a size equal to the number of arguments of the functioncall being visited. --- translate.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translate.cxx b/translate.cxx index d7fa75ded..bd3b6074f 100644 --- a/translate.cxx +++ b/translate.cxx @@ -6150,7 +6150,7 @@ c_unparser::visit_functioncall (functioncall* e) stmt_expr block(*this); - vector cp_arg(e->referents.size(), true); + vector cp_arg(e->args.size(), true); for (unsigned fd = 0; fd < e->referents.size(); fd++) { functiondecl* r = e->referents[fd]; -- 2.43.5