Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent use-after-free when adding subcommand aliases
The add_subcommand_alias routine contained a use-after-free bug which was discovered by valgrind. I actually used the AddressSanitizer to track down this bug - it is much more useful. The actual bug is that old_sc saved a reference to the old array that was realloc-ed and then the function pointer from out the now free'ed array was copied over. Fix this by storing the function pointer into a temporary, then realloc-ing the array and then copy the temporary value into the new array entry. Github-Issue: #122 Reported-By: Mikael Fangel (https://github.com/MikaelFangel)
- Loading branch information