Fixes memleaks reported by ASAN/Valgrind. Reported-by: Sean McGovern <gseanmcg@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>