Fix a bug in get_all_permutations.