Skip to content

Commit

Permalink
Fix: possible allocate memory overflow issue on SmallVector (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
HungMingWu authored Sep 13, 2024
1 parent d077ed8 commit 4e9b249
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/slang/util/SmallVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<difference_type>::max();
return std::numeric_limits<difference_type>::max() / sizeof(T);
}

/// @return true if the array is empty, and false if it has elements in it.
Expand Down

0 comments on commit 4e9b249

Please sign in to comment.