Skip to content

Fix Blob::offset allowing one-past-the-end indices#7125

Open
Chessing234 wants to merge 1 commit into
BVLC:masterfrom
Chessing234:fix/blob-offset-bounds-check
Open

Fix Blob::offset allowing one-past-the-end indices#7125
Chessing234 wants to merge 1 commit into
BVLC:masterfrom
Chessing234:fix/blob-offset-bounds-check

Conversation

@Chessing234

Copy link
Copy Markdown

Blob::offset(n, c, h, w) used CHECK_LE(n, num()), which allows n == num(). For a batch of 10, offset(10) passes the check but points one element past the buffer end.

Valid indices are [0, dim), which is what the vector overload already enforces with CHECK_LT. This change makes the legacy 4D accessor consistent.

Fixes #3420

Made with Cursor

CHECK_LE(n, num()) permitted n == num(), which computes an offset
past the last element. Use CHECK_LT to match the vector overload.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Is this a BUG in blob->offset(n) ?

1 participant