summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-04-29 14:33:43 (GMT)
committerGitHub <noreply@github.com>2021-04-29 14:33:43 (GMT)
commit16f9b070ce084313de37cc73968f70f2cba0b75a (patch)
tree187f19d17a5daff0b61d94fa0669b9277d2d0bd5 /src/H5Pfapl.c
parent138bc52facad0e6be4cfd13a860bb628c1dfd626 (diff)
downloadhdf5-16f9b070ce084313de37cc73968f70f2cba0b75a.zip
hdf5-16f9b070ce084313de37cc73968f70f2cba0b75a.tar.gz
hdf5-16f9b070ce084313de37cc73968f70f2cba0b75a.tar.bz2
Fixes a segfault when H5Pset_mdc_log_options is called multiple times on a fapl (#601)
* Committing clang-format changes * Fixes a segfault when H5Pset_mdc_log_options() is called multiple times An internal string is incorrectly freed when the API call is invoked multiple times on a property list, which will usually cause a segfault to occur. On the first call the log location is NULL so the problem doesn't occur. Fixes HDFFV-11239 * Fixes typos Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index c085b71..fb7b195 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -4221,7 +4221,7 @@ herr_t
H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location, hbool_t start_on_access)
{
H5P_genplist_t *plist; /* Property list pointer */
- char * tmp_location; /* Working location pointer */
+ char * new_location; /* Working location pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -4237,19 +4237,14 @@ H5Pset_mdc_log_options(hid_t plist_id, hbool_t is_enabled, const char *location,
if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "plist_id is not a file access property list")
- /* Get the current location string and free it */
- if (H5P_get(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current log location")
- H5MM_xfree(tmp_location);
-
/* Make a copy of the passed-in location */
- if (NULL == (tmp_location = H5MM_xstrdup(location)))
+ if (NULL == (new_location = H5MM_xstrdup(location)))
HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy passed-in log location")
/* Set values */
if (H5P_set(plist, H5F_ACS_USE_MDC_LOGGING_NAME, &is_enabled) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set is_enabled flag")
- if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &tmp_location) < 0)
+ if (H5P_set(plist, H5F_ACS_MDC_LOG_LOCATION_NAME, &new_location) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set log location")
if (H5P_set(plist, H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME, &start_on_access) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set start_on_access flag")