summaryrefslogtreecommitdiffstats
path: root/src/H5Bcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Bcache.c')
-rw-r--r--src/H5Bcache.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/H5Bcache.c b/src/H5Bcache.c
index 747e4c4..8354e8e 100644
--- a/src/H5Bcache.c
+++ b/src/H5Bcache.c
@@ -312,6 +312,11 @@ H5B__serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNUSED len,
/* node type and level */
*image++ = (uint8_t)shared->type->id;
+
+ /* 2^8 limit: only 1 byte is used to store node level */
+ if(bt->level >= HDpow(2, LEVEL_BITS))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode node level")
+
H5_CHECK_OVERFLOW(bt->level, unsigned, uint8_t);
*image++ = (uint8_t)bt->level;