From 033b7ace5aff35cced7561921789176fb3831cdb Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Thu, 1 Sep 2022 08:19:01 -0500 Subject: Address review comments from downstream merge of #2016 (#2073) (#2081) --- src/H5Aint.c | 8 +++++--- test/dtypes.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/H5Aint.c b/src/H5Aint.c index 876bfa2..0bb9576 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -647,11 +647,13 @@ H5A__read(const H5A_t *attr, const H5T_t *mem_type, void *buf) if (need_bkg) { /* Allocate background buffer */ if (NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) - HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") /* Copy the application buffer into the background buffer if necessary */ - if (need_bkg == H5T_BKG_YES) - H5MM_memcpy(bkg_buf, buf, (dst_type_size * nelmts)); + if (need_bkg == H5T_BKG_YES) { + HDassert(buf_size >= (dst_type_size * nelmts)); + H5MM_memcpy(bkg_buf, buf, dst_type_size * nelmts); + } } /* Perform datatype conversion. */ diff --git a/test/dtypes.c b/test/dtypes.c index c72fce0..75a8f6e 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -3432,7 +3432,7 @@ test_compound_15_attr(void) if ((attr_id = H5Acreate_by_name(file, ".", "attr_cmpd", cmpd_f_tid, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - FAIL_PUTS_ERROR("Can't create dataset\n"); + FAIL_PUTS_ERROR("Can't create attribute\n"); if (H5Awrite(attr_id, cmpd_f_tid, &wdata1) < 0) FAIL_PUTS_ERROR("Can't write data\n"); -- cgit v0.12