Fixed null pointer issue on Mac platform