BUG: unchecked malloc in heapsort