Fix a segmentation error caused by illigal depth dealing