Corrected several static analysis issues related to potential null pointer dereferences and memory leaks.