Skip to content

Keep the given running value in Zlib.crc32(nil, crc) and Zlib.adler32(nil, adler) - #176

Open
segiddins wants to merge 1 commit into
ruby:masterfrom
segiddins:segiddins/checksum-nil-running-value
Open

segiddins wants to merge 1 commit into
ruby:masterfrom
segiddins:segiddins/checksum-nil-running-value

Conversation

@segiddins

Copy link
Copy Markdown
Contributor

For a nil string the checksum was computed as crc32(crc, NULL, 0), but zlib returns the initial value whenever the buffer is NULL, discarding the running value that was passed in.

Zlib.crc32(nil, 1234)
# expected: 1234 (as Zlib.crc32("", 1234))
# actual:   0
Zlib.adler32(nil, 1234)
# expected: 1234
# actual:   1

…(nil, adler)

For a nil string the checksum was computed as crc32(crc, NULL, 0), but zlib returns the initial value whenever the buffer is NULL, discarding the running value that was passed in.

```ruby
Zlib.crc32(nil, 1234)
# expected: 1234 (as Zlib.crc32("", 1234))
# actual:   0
Zlib.adler32(nil, 1234)
# expected: 1234
# actual:   1
```

Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant