Skip to content

fix: buffer slice last byte out of range#2698

Open
3l0w wants to merge 1 commit intoWerWolv:masterfrom
3l0w:master
Open

fix: buffer slice last byte out of range#2698
3l0w wants to merge 1 commit intoWerWolv:masterfrom
3l0w:master

Conversation

@3l0w
Copy link
Copy Markdown

@3l0w 3l0w commented Apr 4, 2026

Problem description

Fixes: #1880
The slice buffer node 'to' variable cannot be set to capture the last byte, throwing 'to' input out of range.

Implementation description

The upper bound check was an greater or equals than, so switching it to a greater than fixes the issue.

@paxcut
Copy link
Copy Markdown
Collaborator

paxcut commented Apr 26, 2026

I guess we have two choices. We can use C-like indices of 0..N-1 to slice N elements. ImHex uses an iterator like system where 0..N selects the first N elements so that the end number is one past the end of the buffer.
The fix proposed here follows ImHex's model.To implement a C like index system use:

this->setBufferOnOutput(3, std::vector(input.begin() + u64(from), input.begin() + u64(to + 1)));

and leave the error condition for to as it was.

I think either one is fine but I wanted to make sure that the choice is deliberate and not accidental due to the bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Slice buffer node range excludes "To" index

2 participants