Fix segmentation fault when destination directory cannot be created