Fix the potential segmentation fault