From 5de9d63ff433f146b29d7331c07ac6fae9a98a5e Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Wed, 31 Aug 2022 11:01:05 -0500 Subject: Address review comments from downstream merge of #2016 (#2073) --- 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 4403da8..e6440bb 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -761,11 +761,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 1cbaf6c..42a7cc9 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -3434,7 +3434,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