From 85b95b8e32fe6020a05544f634d34529cf095ba3 Mon Sep 17 00:00:00 2001 From: Lukasz Dorau Date: Wed, 9 Aug 2023 14:36:08 +0200 Subject: [PATCH] Verify size in alignToBin() Size in alignToBin() must not be less than the StepFactor (8). It fixes the Coverity issues: 449474 and 913880. Signed-off-by: Lukasz Dorau --- src/tbbmalloc/large_objects.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tbbmalloc/large_objects.h b/src/tbbmalloc/large_objects.h index ff205ccd8c..8e8543bc79 100644 --- a/src/tbbmalloc/large_objects.h +++ b/src/tbbmalloc/large_objects.h @@ -80,6 +80,7 @@ struct HugeBinStructureProps { static const unsigned NumBins = (MaxSizeExp - MinSizeExp) * StepFactor; static size_t alignToBin(size_t size) { + MALLOC_ASSERT(size >= StepFactor, "Size must not be less than the StepFactor"); size_t minorStepExp = BitScanRev(size) - StepFactorExp; return alignUp(size, 1ULL << minorStepExp); }