From bfebf7da19a472d9c2540e4066670ee1625f6651 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 20 Mar 2009 15:48:19 +0000 Subject: [PATCH] don't segfault upon failed strdup * sa-confdb.c (load_config): Handle out-of-memory. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1881 fd59a12c-fef9-0310-b244-a6a79926bd2f --- lib/sa-confdb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/sa-confdb.c b/lib/sa-confdb.c index 8871cdd0..709179a6 100644 --- a/lib/sa-confdb.c +++ b/lib/sa-confdb.c @@ -103,11 +103,15 @@ static int load_config(void) /* User's bootstrap config service */ config_iface = getenv("COROSYNC_DEFAULT_CONFIG_IFACE"); if (!config_iface) { - config_iface = strdup("corosync_parser"); + if ((config_iface = strdup("corosync_parser")) == NULL) { + return -1; + } } /* Make a copy so we can deface it with strtok */ - config_iface = strdup(config_iface); + if ((config_iface = strdup(config_iface)) == NULL) { + return -1; + } iface = strtok(config_iface, ":"); while (iface)