nir: fix memleak in error path