[CID-26975, 36747] Fix memory leak and dereference after null check