From 4e9b24973f80357337976360fb9e6cbc6febfec7 Mon Sep 17 00:00:00 2001 From: HungMingWu Date: Fri, 13 Sep 2024 21:58:13 +0800 Subject: [PATCH] Fix: possible allocate memory overflow issue on SmallVector (#1119) --- include/slang/util/SmallVector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/slang/util/SmallVector.h b/include/slang/util/SmallVector.h index a8609465f..007db63a7 100644 --- a/include/slang/util/SmallVector.h +++ b/include/slang/util/SmallVector.h @@ -114,7 +114,7 @@ class SmallVectorBase { /// @return the maximum number of elements that could ever fit in the array, /// assuming the system had enough memory to support it. [[nodiscard]] constexpr size_type max_size() const noexcept { - return std::numeric_limits::max(); + return std::numeric_limits::max() / sizeof(T); } /// @return true if the array is empty, and false if it has elements in it.