From 18130847c19f118b0fae5a76edcc172a5111c632 Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 11 May 2023 20:09:46 +0200 Subject: [PATCH] libc: Fix some environment-related bugs --- libc/src/env.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libc/src/env.cpp b/libc/src/env.cpp index 0fdac72a..60ab6971 100644 --- a/libc/src/env.cpp +++ b/libc/src/env.cpp @@ -54,10 +54,10 @@ static Result _try_move_env() if (!env) { + TRY(g_dynamic_env.try_append(nullptr)); guard.deactivate(); env_is_dynamic = true; environ = g_dynamic_env.data(); - check(!environ); return {}; } @@ -109,10 +109,12 @@ extern "C" { if (element) free(element); } + + g_dynamic_env.clear(); } - env_is_dynamic = false; environ = nullptr; + env_is_dynamic = false; return 0; }