summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Henderson <jhenderson@hdfgroup.org>2019-01-04 20:06:10 (GMT)
committerJordan Henderson <jhenderson@hdfgroup.org>2019-01-04 20:06:10 (GMT)
commitb0feaecdb94739086f57981b5f80d3ceafcef183 (patch)
tree6b3db4bbf45576b2074d742631a4be5672b5f479
parent8887c357eed773858f76afadb9c9ab845f05d45a (diff)
parent659dd9bccf69f32bfdd01dc49410116ec5c1b0bb (diff)
downloadhdf5-b0feaecdb94739086f57981b5f80d3ceafcef183.zip
hdf5-b0feaecdb94739086f57981b5f80d3ceafcef183.tar.gz
hdf5-b0feaecdb94739086f57981b5f80d3ceafcef183.tar.bz2
Merge pull request #1425 in HDFFV/hdf5 from ~JHENDERSON/hdf5:develop to develop
* commit '659dd9bccf69f32bfdd01dc49410116ec5c1b0bb': Align H5Lcreate_ud behavior with documentation for NULL udata pointer
-rw-r--r--src/H5L.c2
-rw-r--r--test/links.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/H5L.c b/src/H5L.c
index 33e561a..1f45740 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -648,6 +648,8 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified")
if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class")
+ if(!udata && udata_size)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata cannot be NULL if udata_size is non-zero")
/* Check the group access property list */
if(H5P_DEFAULT == lcpl_id)
diff --git a/test/links.c b/test/links.c
index b09ddb1..520f784 100644
--- a/test/links.c
+++ b/test/links.c
@@ -8823,6 +8823,12 @@ ud_link_errors(hid_t fapl, hbool_t new_format)
TEST_ERROR
} H5E_END_TRY
+ /* Try to create a link with H5Lcreate_ud that has a NULL udata pointer, but a non-zero udata_size value */
+ H5E_BEGIN_TRY {
+ if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT) >= 0)
+ TEST_ERROR
+ } H5E_END_TRY;
+
/* Create a user-defined link to the group. */
strcpy(group_name, "/group");
if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR