diff options
author | raylu-hdf <60487644+raylu-hdf@users.noreply.github.com> | 2022-11-17 22:29:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-17 22:29:21 (GMT) |
commit | ee4d92e01bd7a48624af7a8a811faea00724daff (patch) | |
tree | 28df5f8df1ea1ed0504d42ad9afc5a5f540e5071 /src/H5CX.c | |
parent | 9dd36f016a4316b94f5df15856d228de01d304c6 (diff) | |
download | hdf5-ee4d92e01bd7a48624af7a8a811faea00724daff.zip hdf5-ee4d92e01bd7a48624af7a8a811faea00724daff.tar.gz hdf5-ee4d92e01bd7a48624af7a8a811faea00724daff.tar.bz2 |
Bug Fix: Segfault in H5CX_get_vol_wrap_ctx when H5VLwrap_register is called from an application (#2248)
* Jira HDFFV-10881: Segfault in H5CX_get_vol_wrap_ctx when H5VLwrap_register is called from an application. A quick and simple fix to make it fail with a relevant error message.
* Format changes.
* Committing clang-format changes
* Minor change: split one condition check into two for clarity.
* Adding doxygen comment for H5VLwrap_register.
* Minor change: adding a little more detail to the Doxygen comment for H5VLwrap_register.
Diffstat (limited to 'src/H5CX.c')
-rw-r--r-- | src/H5CX.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -1621,12 +1621,20 @@ H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) H5CX_node_t **head = NULL; /* Pointer to head of API context list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOERR + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(vol_wrap_ctx); head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ - HDassert(head && *head); + + /* No error is expected at this point. But in case an application calls H5VLwrap_register + * which doesn't reset the API context and there is no context, returns a relevant error here + */ + if (!head) + HGOTO_ERROR(H5E_CONTEXT, H5E_UNINITIALIZED, FAIL, "the API context isn't available") + + if (!(*head)) + HGOTO_ERROR(H5E_CONTEXT, H5E_CANTGET, FAIL, "unable to get the current API context") /* Check for value that was set */ if ((*head)->ctx.vol_wrap_ctx_valid) @@ -1635,6 +1643,7 @@ H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) else *vol_wrap_ctx = NULL; +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX_get_vol_wrap_ctx() */ |