diff --git a/binfmt/libelf/libelf_addrenv.c b/binfmt/libelf/libelf_addrenv.c index 3e44d2eab0..035e498ade 100644 --- a/binfmt/libelf/libelf_addrenv.c +++ b/binfmt/libelf/libelf_addrenv.c @@ -259,7 +259,9 @@ void elf_addrenv_free(FAR struct elf_loadinfo_s *loadinfo) /* Free the address environment */ + elf_addrenv_select(loadinfo); ret = up_addrenv_destroy(&loadinfo->addrenv); + elf_addrenv_restore(loadinfo); if (ret < 0) { berr("ERROR: up_addrenv_destroy failed: %d\n", ret);