I am not able explain why this doesn't fail everywhere. If
HWLOC_PLUGINS_VERBOSE is not set, atoi() gets called with a NULL pointer, and
the behavior in that case is undocumented.

--Guy
>From 36a79abe46356ff360e192039fae3829b34b7997 Mon Sep 17 00:00:00 2001
From: Guy Streeter <stree...@redhat.com>
List-Post: hwloc-devel@lists.open-mpi.org
Date: Fri, 9 Oct 2015 15:49:15 -0500
Subject: [PATCH] Check the return value of getenv() in
 hwloc_plugin_check_namespace

---
 include/hwloc/plugins.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hwloc/plugins.h b/include/hwloc/plugins.h
index dd4e46a..ef78806 100644
--- a/include/hwloc/plugins.h
+++ b/include/hwloc/plugins.h
@@ -353,7 +353,7 @@ hwloc_plugin_check_namespace(const char *pluginname __hwloc_attribute_unused, co
     static int verboseenv_value = 0;
     if (!verboseenv_checked) {
       const char *verboseenv = getenv("HWLOC_PLUGINS_VERBOSE");
-      verboseenv_value = atoi(verboseenv);
+      verboseenv_value = verboseenv ? atoi(verboseenv) : 0;
       verboseenv_checked = 1;
     }
     if (verboseenv_value)
-- 
2.1.0

Reply via email to