commit 046afa537273fd8ab0aa31a88fe625c196f23474
Author: Sergey Poznyakoff <gray@gnu.org>
Date:   Sun Aug 4 14:48:30 2024 +0300
Forwarded: not-needed

    Avoid infinite recursion in xnomem.

diff --git a/src/pound.c b/src/pound.c
index 7df7987..8e4156f 100644
--- a/src/pound.c
+++ b/src/pound.c
@@ -107,24 +107,32 @@ logmsg (const int priority, const char *fmt, ...)
 }
 
 /*
- * This is used as exit point if memory allocation failures occur at program
- * startup (e.g. when parsing config or the like).
+ * Log an out of memory condition and return.
+ * Take care not to use [v]logmsg as this could create infinite recursion.
  */
 void
-xnomem (void)
+lognomem (void)
 {
-  logmsg (LOG_CRIT, "out of memory");
-  exit (1);
+  if (log_facility == -1 || print_log)
+    {
+      fprintf (stderr, "%s: out of memory\n", progname);
+    }
+
+  if (log_facility != -1)
+    {
+      syslog (LOG_CRIT, "out of memory");
+    }
 }
 
 /*
- * This is used as json_memabrt hook.  The code in svc.c handles memory
- * allocation failures gracefully and returns 500 if any occurs.
+ * This is used as exit point if memory allocation failures occur at program
+ * startup (e.g. when parsing config or the like).
  */
 void
-lognomem (void)
+xnomem (void)
 {
-  logmsg (LOG_CRIT, "out of memory");
+  lognomem ();
+  exit (1);
 }
 
 /*
