This bug was added in 461803fe
For env vars edited by the recipe, we shouldn't set the old_env to an incorrect value which also contains any changes made by the recipe. @modify_environment will take care to restore the original env when we return from the build step for those vars.
No idea why this wasn't caught earlier, an easy way to reproduce is to do
buildone glib libusrsctp.
@ylatuya, this might also have been what you saw while updating the mingw toolchain in addition to the leak-env-on-exception bug.