fix memory leak and null pointer dereference
2 files changed