summaryrefslogtreecommitdiffstats
path: root/src/H5ESint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5ESint.c')
-rw-r--r--src/H5ESint.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/H5ESint.c b/src/H5ESint.c
index 6f9efe9..b3edaaa 100644
--- a/src/H5ESint.c
+++ b/src/H5ESint.c
@@ -294,7 +294,10 @@ H5ES__insert(H5ES_t *es, H5VL_t *connector, void *request_token, const char *app
* there's no need to duplicate it.
*/
ev->op_info.api_name = caller;
- if (NULL == (ev->op_info.api_args = H5MM_xstrdup(api_args)))
+ ev->op_info.api_args = H5MM_xstrdup(api_args);
+
+ /* 'api_args' is allowed to be NULL, but if it isn't, check for allocation failure */
+ if (api_args && NULL == ev->op_info.api_args)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, FAIL, "can't copy API routine arguments")
/* Append fully initialized event onto the event set's 'active' list */
@@ -817,14 +820,21 @@ H5ES__get_err_info_cb(H5ES_event_t *ev, void *_ctx)
/* The 'app_func_name', 'app_file_name', and 'api_name' strings are statically allocated (by the compiler)
* so there's no need to duplicate them internally, but they are duplicated
* here, when they are given back to the user.
+ *
+ * They are also allowed to be NULL, so only check for NULL values from
+ * the strdup when the original string is non-NULL.
*/
- if (NULL == (ctx->curr_err_info->api_name = H5MM_strdup(ev->op_info.api_name)))
+ ctx->curr_err_info->api_name = H5MM_strdup(ev->op_info.api_name);
+ if (ev->op_info.api_name && NULL == ctx->curr_err_info->api_name)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API routine name")
- if (NULL == (ctx->curr_err_info->api_args = H5MM_strdup(ev->op_info.api_args)))
+ ctx->curr_err_info->api_args = H5MM_strdup(ev->op_info.api_args);
+ if (ev->op_info.api_args && NULL == ctx->curr_err_info->api_args)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 API routine arguments")
- if (NULL == (ctx->curr_err_info->app_file_name = H5MM_strdup(ev->op_info.app_file_name)))
+ ctx->curr_err_info->app_file_name = H5MM_strdup(ev->op_info.app_file_name);
+ if (ev->op_info.app_file_name && NULL == ctx->curr_err_info->app_file_name)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 application file name")
- if (NULL == (ctx->curr_err_info->app_func_name = H5MM_strdup(ev->op_info.app_func_name)))
+ ctx->curr_err_info->app_func_name = H5MM_strdup(ev->op_info.app_func_name);
+ if (ev->op_info.app_func_name && NULL == ctx->curr_err_info->app_func_name)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTALLOC, H5_ITER_ERROR, "can't copy HDF5 application function name")
ctx->curr_err_info->app_line_num = ev->op_info.app_line_num;
ctx->curr_err_info->op_ins_count = ev->op_info.op_ins_count;