-
Notifications
You must be signed in to change notification settings - Fork 21
Add offset in dynamic_bitset #567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -334,27 +334,40 @@ namespace sparrow | |||||||||||
| return std::move(m_buffer); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @brief Returns the bit offset from the start of the buffer. | ||||||||||||
| * | ||||||||||||
| * This value indicates how many bits from the beginning of the underlying storage | ||||||||||||
| * are skipped before the bitset's logical start. It is set during construction and | ||||||||||||
| * remains constant for the lifetime of the bitset. | ||||||||||||
| * | ||||||||||||
| * @return The number of bits offset from the start of the buffer. | ||||||||||||
| */ | ||||||||||||
| [[nodiscard]] size_t offset() const noexcept; | ||||||||||||
|
||||||||||||
| [[nodiscard]] size_t offset() const noexcept; | |
| [[nodiscard]] size_t offset() const noexcept | |
| { | |
| return m_offset; | |
| } |
Alex-PLACET marked this conversation as resolved.
Show resolved
Hide resolved
Alex-PLACET marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Sep 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding offset to the size for block count calculation is incorrect. The block count should be based on the actual storage needed for the bits, not the logical size plus offset. This could cause buffer overruns when the offset pushes beyond allocated memory.
| const size_type new_block_count = compute_block_count(n + m_offset); | |
| const size_type new_block_count = compute_block_count(n); |
Uh oh!
There was an error while loading. Please reload this page.