Skip to content

LZ4BlockInputStream.available() returns a negative value after an empty block #108

Closed

Description

@yawkat

In refill(), the empty-block branch (originalLen == 0 && compressedLen == 0) sets originalLen to 0 but leaves o at its value from the previous block. available() (return originalLen - o;, line 190) then returns -o. This happens with the default stopOnEmptyBlock=true too.

Fix: set o = 0 in the empty-block branch. Otherwise, clamp available() to at least 0.

Activity

  1. added
    bug
    on Sep 25, 2026
  2. self-assigned this
    on Sep 25, 2026
  3. added a commit that references this issue on Sep 25, 2026
    788980d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions