Fixed segmentation error resulting in core dump by properly initializing pointer to NULL before use