summaryrefslogtreecommitdiff
path: root/crypto/mem_sec.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/mem_sec.c')
-rw-r--r--crypto/mem_sec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/mem_sec.c b/crypto/mem_sec.c
index 4ccff34e5e..0c79b43658 100644
--- a/crypto/mem_sec.c
+++ b/crypto/mem_sec.c
@@ -356,6 +356,10 @@ static int sh_init(size_t size, int minsize)
sh.minsize = minsize;
sh.bittable_size = (sh.arena_size / sh.minsize) * 2;
+ /* Prevent allocations of size 0 later on */
+ if (sh.bittable_size >> 3 == 0)
+ goto err;
+
sh.freelist_size = -1;
for (i = sh.bittable_size; i; i >>= 1)
sh.freelist_size++;