Fix a heap leak in sort.c