bug-22060: Clean up potential use of variable after free