You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add checked SLEB128 encoding and decoding for byte cursors #718
enhancementA request for a new feature or improvement.help wantedThe issue requires extra attention or help from others.needs testingIssues that require additional testing or verification.
The completed #674 added unsigned LEB128 to std/bytes/leb128.wave. Binary formats using signed LEB128 still require callers to implement sign extension and overflow checks themselves.
Scope
Add bytes_reader_read_sleb128_i64 and bytes_writer_write_sleb128_i64 using the existing cursor and error types. Read at most ten bytes, accepting terminating non-minimal encodings only when they represent an i64. Writers emit the shortest encoding.
Return BYTES_ERROR_INVALID for null pointers or invalid cursor state, BYTES_ERROR_EOF for input ending before termination within the ten-byte bound, BYTES_ERROR_OVERFLOW for an unrepresentable value or a continuation beyond that bound, and BYTES_ERROR_NO_SPACE for insufficient output capacity.
Reader failure must preserve position and output; writer failure must preserve position and bytes. Check tenth-byte sign extension before unsafe shifts. Keep ULEB128 behavior unchanged. This is SLEB128, not ZigZag encoding.
Completion criteria
Implement both operations without heap allocation, libc, or a new dependency.
Verify exact encodings for 0, -1, 63, 64, -64, -65, and both i64 extrema.
Cover truncation, unterminated/overflowing encodings, and invalid tenth-byte sign extension.
Cover invalid/null cursors and output pointers, valid non-minimal encodings, consecutive values from a nonzero position, and insufficient output capacity.
Verify error codes and state preservation on every failure path.
Run new and existing ULEB128 regressions at O0/O2.
changed the title [-][Proposal]: Add checked signed LEB128 byte-cursor operations[/-][+]Add checked SLEB128 encoding and decoding for byte cursors[/+]on Sep 24, 2026
enhancementA request for a new feature or improvement.help wantedThe issue requires extra attention or help from others.needs testingIssues that require additional testing or verification.
Activity
[-][Proposal]: Add checked signed LEB128 byte-cursor operations[/-][+]Add checked SLEB128 encoding and decoding for byte cursors[/+]Record typed HIR conversions and add checked std operations (#744)