Fix a possible use-after-free in custom_exts_free