From 0cc028a36c47b3ba75db3a15e5196f08e8094c72 Mon Sep 17 00:00:00 2001 From: raylu-hdf <60487644+raylu-hdf@users.noreply.github.com> Date: Fri, 17 Feb 2023 16:15:48 -0600 Subject: GitHub #2417: to avoid the pass-through VOL failing in unexpected places, make sure the underneath VOL ID is specified. (#2475) * GitHub #2417: to avoid the pass-through VOL failing in unexpected places, make sure the underneath VOL ID is specified. * Committing clang-format changes --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- src/H5VLpassthru.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index d7e730a..4ceac7a 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -388,6 +388,7 @@ H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id) new_obj = (H5VL_pass_through_t *)calloc(1, sizeof(H5VL_pass_through_t)); new_obj->under_object = under_obj; new_obj->under_vol_id = under_vol_id; + H5Iinc_ref(new_obj->under_vol_id); return new_obj; @@ -520,12 +521,27 @@ H5VL_pass_through_info_copy(const void *_info) printf("------- PASS THROUGH VOL INFO Copy\n"); #endif + /* Make sure the underneath VOL of this pass-through VOL is specified */ + if (!info) { + printf("\nH5VLpassthru.c line %d in %s: info for pass-through VOL can't be null\n", __LINE__, + __func__); + return NULL; + } + + if (H5Iis_valid(info->under_vol_id) <= 0) { + printf("\nH5VLpassthru.c line %d in %s: not a valid underneath VOL ID for pass-through VOL\n", + __LINE__, __func__); + return NULL; + } + /* Allocate new VOL info struct for the pass through connector */ new_info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); /* Increment reference count on underlying VOL ID, and copy the VOL info */ new_info->under_vol_id = info->under_vol_id; + H5Iinc_ref(new_info->under_vol_id); + if (info->under_vol_info) H5VLcopy_connector_info(new_info->under_vol_id, &(new_info->under_vol_info), info->under_vol_info); @@ -753,7 +769,9 @@ H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) /* Increment reference count on underlying VOL ID, and copy the VOL info */ new_wrap_ctx->under_vol_id = o->under_vol_id; + H5Iinc_ref(new_wrap_ctx->under_vol_id); + H5VLget_wrap_ctx(o->under_object, o->under_vol_id, &new_wrap_ctx->under_wrap_ctx); /* Set wrap context to return */ @@ -2605,6 +2623,19 @@ H5VL_pass_through_introspect_get_cap_flags(const void *_info, uint64_t *cap_flag printf("------- PASS THROUGH VOL INTROSPECT GetCapFlags\n"); #endif + /* Make sure the underneath VOL of this pass-through VOL is specified */ + if (!info) { + printf("\nH5VLpassthru.c line %d in %s: info for pass-through VOL can't be null\n", __LINE__, + __func__); + return -1; + } + + if (H5Iis_valid(info->under_vol_id) <= 0) { + printf("\nH5VLpassthru.c line %d in %s: not a valid underneath VOL ID for pass-through VOL\n", + __LINE__, __func__); + return -1; + } + /* Invoke the query on the underlying VOL connector */ ret_value = H5VLintrospect_get_cap_flags(info->under_vol_info, info->under_vol_id, cap_flags); -- cgit v0.12