From 256524a2afd927ed056177d2e59753a6927618d4 Mon Sep 17 00:00:00 2001 From: Hyo-Kyung Lee Date: Mon, 26 Aug 2024 21:51:01 -0500 Subject: [PATCH] Fix Address Sanitizer error for realloc() --- src/H5Centry.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/H5Centry.c b/src/H5Centry.c index 1ca7479cf7e..5d1a0197b8d 100644 --- a/src/H5Centry.c +++ b/src/H5Centry.c @@ -1105,7 +1105,12 @@ H5C__load_entry(H5F_t *f, HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "actual_len exceeds EOA"); /* Expand buffer to new size */ - if (NULL == (new_image = H5MM_realloc(image, actual_len + H5C_IMAGE_EXTRA_SPACE))) + size_t s = actual_len + (size_t)H5C_IMAGE_EXTRA_SPACE; + if (s > 0x10000000000) { + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "actual_len exceeds 0x10000000000"); + } + new_image = H5MM_realloc(image, s); + if (NULL == new_image) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()"); image = (uint8_t *)new_image; #if H5C_DO_MEMORY_SANITY_CHECKS