• Peter Sanford's avatar
    Fix use after free and leak in get_arg_values · 74f2b9e4
    Peter Sanford authored
    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
    74f2b9e4
printf.h 641 Bytes