Fix #80226: imap_sort() leaks sortpgm memory We need to free what we have allocated. Closes GH-6327.