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