]> Savannah Git Hosting - gnulib.git/commitdiff
putenv: Don't crash upon out-of-memory.
authorBruno Haible <bruno@clisp.org>
Thu, 6 Jun 2024 00:24:44 +0000 (02:24 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 6 Jun 2024 23:27:38 +0000 (01:27 +0200)
* lib/putenv.c (_unsetenv): Handle malloc failure.

ChangeLog
lib/putenv.c

index 4cccffbc14a90c20754fde1aa1ce81086da4f8f8..8005d2856bef35280c9cd93e69741e283853e7ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-06-05  Bruno Haible  <bruno@clisp.org>
+
+       putenv: Don't crash upon out-of-memory.
+       * lib/putenv.c (_unsetenv): Handle malloc failure.
+
 2024-06-05  Bruno Haible  <bruno@clisp.org>
 
        putenv: Improve comments.
index 525d12aed971c26792161446b1e9148223def2bc..1d70717e0f7f9456b5b6bc12c47ed0603a330d1c 100644 (file)
@@ -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;