From 87b6c1cf99f9c71057bec9e8b54dbd7a38fe530e Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Fri, 2 May 2014 16:39:45 +0000 Subject: [PATCH] Add some protection to ensure that dstore doesn't segfault if uninitialized This commit was SVN r31606. --- opal/mca/dstore/base/dstore_base_stubs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/opal/mca/dstore/base/dstore_base_stubs.c b/opal/mca/dstore/base/dstore_base_stubs.c index 2040f31d83..140b89ce41 100644 --- a/opal/mca/dstore/base/dstore_base_stubs.c +++ b/opal/mca/dstore/base/dstore_base_stubs.c @@ -83,6 +83,10 @@ int opal_dstore_base_store(int dstorehandle, { opal_dstore_handle_t *hdl; + if (dstorehandle < 0) { + return OPAL_ERR_NOT_INITIALIZED; + } + if (NULL == (hdl = (opal_dstore_handle_t*)opal_pointer_array_get_item(&opal_dstore_base.handles, dstorehandle))) { OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND); return OPAL_ERR_NOT_FOUND; @@ -99,6 +103,11 @@ void opal_dstore_base_commit(int dstorehandle, { opal_dstore_handle_t *hdl; + if (dstorehandle < 0) { + OPAL_ERROR_LOG(OPAL_ERR_NOT_INITIALIZED); + return; + } + if (NULL == (hdl = (opal_dstore_handle_t*)opal_pointer_array_get_item(&opal_dstore_base.handles, dstorehandle))) { OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND); return; @@ -119,6 +128,10 @@ int opal_dstore_base_fetch(int dstorehandle, { opal_dstore_handle_t *hdl; + if (dstorehandle < 0) { + return OPAL_ERR_NOT_INITIALIZED; + } + if (NULL == (hdl = (opal_dstore_handle_t*)opal_pointer_array_get_item(&opal_dstore_base.handles, dstorehandle))) { OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND); return OPAL_ERR_NOT_FOUND; @@ -136,6 +149,10 @@ int opal_dstore_base_remove_data(int dstorehandle, { opal_dstore_handle_t *hdl; + if (dstorehandle < 0) { + return OPAL_ERR_NOT_INITIALIZED; + } + if (NULL == (hdl = (opal_dstore_handle_t*)opal_pointer_array_get_item(&opal_dstore_base.handles, dstorehandle))) { OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND); return OPAL_ERR_NOT_FOUND;