summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-10-27 21:15:39 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-10-27 21:15:39 (GMT)
commit9bc6644ed194addfd528870de3f41fbd2d49e711 (patch)
treed17f5223d29f1754618e302f251b0066706cd5d2 /src
parentfb6ecf33b0e39b5568b648f9c6a59e7d95f5547c (diff)
downloadhdf5-9bc6644ed194addfd528870de3f41fbd2d49e711.zip
hdf5-9bc6644ed194addfd528870de3f41fbd2d49e711.tar.gz
hdf5-9bc6644ed194addfd528870de3f41fbd2d49e711.tar.bz2
Duplicate name of VOL plugin class, to avoid continuing to refer to the caller's
string when making a copy of the class for internal use.
Diffstat (limited to 'src')
-rw-r--r--src/H5VLint.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/H5VLint.c b/src/H5VLint.c
index f0a5253..b00355d 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -178,11 +178,11 @@ H5VL_term_package(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
- if (H5_PKG_INIT_VAR) {
+ if(H5_PKG_INIT_VAR) {
if (H5I_nmembers(H5I_VOL) > 0) {
(void)H5I_clear_type(H5I_VOL, FALSE, FALSE);
n++;
- }
+ } /* end if */
else {
/* Destroy the VOL plugin ID group */
n += (H5I_dec_type_ref(H5I_VOL) > 0);
@@ -190,8 +190,8 @@ H5VL_term_package(void)
/* Mark interface as closed */
if (0 == n)
H5_PKG_INIT_VAR = FALSE;
- }
- }
+ } /* end else */
+ } /* end if */
FUNC_LEAVE_NOAPI(n)
} /* end H5VL_term_package() */
@@ -223,7 +223,8 @@ H5VL__free_cls(H5VL_class_t *cls)
if(cls->terminate && cls->terminate() < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL plugin did not terminate cleanly")
- /* XXX (VOL MERGE): We'll leak memory if the name string was dynamically allocated. */
+ /* Release the class */
+ H5MM_xfree(cls->name);
H5FL_FREE(H5VL_class_t, cls);
done:
@@ -516,8 +517,10 @@ H5VL_register_plugin(const void *_cls, hbool_t app_ref, hid_t vipl_id)
/* Copy the class structure so the caller can reuse or free it */
if (NULL == (saved = H5FL_CALLOC(H5VL_class_t)))
- HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed for VOL plugin class struct")
+ HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL plugin class struct")
HDmemcpy(saved, cls, sizeof(H5VL_class_t));
+ if(NULL == (saved->name = H5MM_strdup(cls->name)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL plugin name")
/* Initialize the VOL plugin */
if(cls->initialize && cls->initialize(vipl_id) < 0)