From adb76c754290c328a88438af89e491ece7e6a9c5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 6 Jun 2024 02:24:44 +0200
Subject: [PATCH] putenv: Don't crash upon out-of-memory.

* lib/putenv.c (_unsetenv): Handle malloc failure.

Reference:https://github.com/coreutils/gnulib/commit/adb76c754290c328a88438af89e491ece7e6a9c5
Conflict:delete ChangeLog

---
 lib/putenv.c | 2 ++
 1 files changed, 2 insertions(+)

diff --git a/lib/putenv.c b/lib/putenv.c
index 525d12ae..1d70717e 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -92,6 +92,8 @@ _unsetenv (const char *name)
   {
     int putenv_result;
     char *name_ = malloc (len + 2);
+    if (name_ == NULL)
+      return -1;
     memcpy (name_, name, len);
     name_[len] = '=';
     name_[len + 1] = 0;
-- 
2.43.0

