A failed strdup here would cause silent non-parsing.
I.e., it'd ignore any COROSYNC_DEFAULT_CONFIG_IFACE envvar setting
and would fail to fall back on using "corosync_parser".
Better just to exit.

>From ba3c03e5ffa4acac4aa83deb2909fe63088eb6d1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Mon, 20 Apr 2009 17:57:04 +0200
Subject: [PATCH] exce/main.c: handle strdup failure

* exec/main.c (main): Upon strdup failure, log the error and exit.
---
 exec/main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/exec/main.c b/exec/main.c
index 473f507..f7cd42c 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -790,7 +790,10 @@ int main (int argc, char **argv)
        }

        /* Make a copy so we can deface it with strtok */
-       config_iface = strdup(config_iface_init);
+       if ((config_iface = strdup(config_iface_init)) == NULL) {
+               log_printf (LOGSYS_LEVEL_ERROR, "exhausted virtual memory");
+               corosync_exit_error (AIS_DONE_OBJDB);
+       }

        iface = strtok(config_iface, ":");
        while (iface)
--
1.6.3.rc0.230.g3edd6
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to