Fix a bug that causes a segmentation fault in append_path