Fix use after free and leak in get_arg_values
Previously get_arg_values was returning a vector of uint64_t values that could be passed directly to printf(3). For string values get_arg_values was returning a pointer to a char*. For some cases it was attempting to handle freeing the char* memory via a stack allocated std::vector. Unfortunately, this was stack allocated in get_arg_values so the char* data would get freed before it was used in the subsequent call to printf(). In other cases get_arg_values was not freeing char* values and was leaking memory (probe, stack, and ustack). get_arg_values() now returns a vector of objects of type IPrintable instead of uint64_t values. Each object has a method .value() that returns the uint64_t value usable by printf(). For strings this allows us to keep around the original std::string until after we've called printf(), so we don't need to strdup() anymore. Fixes #194
Showing
Please register or sign in to comment