libc: Fix some environment-related bugs

This commit is contained in:
apio 2023-05-11 20:09:46 +02:00
parent 411c6c40cd
commit 18130847c1
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -54,10 +54,10 @@ static Result<void> _try_move_env()
if (!env) if (!env)
{ {
TRY(g_dynamic_env.try_append(nullptr));
guard.deactivate(); guard.deactivate();
env_is_dynamic = true; env_is_dynamic = true;
environ = g_dynamic_env.data(); environ = g_dynamic_env.data();
check(!environ);
return {}; return {};
} }
@ -109,10 +109,12 @@ extern "C"
{ {
if (element) free(element); if (element) free(element);
} }
g_dynamic_env.clear();
} }
env_is_dynamic = false;
environ = nullptr; environ = nullptr;
env_is_dynamic = false;
return 0; return 0;
} }