Skip to content

Return 1 byte length for zero len values when determining spaceForLength#1

Open
ou05020 wants to merge 2 commits intophilpearl:masterfrom
ou05020:master
Open

Return 1 byte length for zero len values when determining spaceForLength#1
ou05020 wants to merge 2 commits intophilpearl:masterfrom
ou05020:master

Conversation

@ou05020
Copy link

@ou05020 ou05020 commented Jan 19, 2020

bits.Len returns 0 when len == 0. That results in a zero result returned by spaceForLength due to integer division (6/7). The writeLength function is then called using 1 byte to write the zero length value leading to a discrepancy between reserved (0) and written (1) number of bytes.

This causes incorrect values to be returned for empty strings in Stringbank.Get.

bits.Len returns 0 when len == 0. That results in a zero result returned by `spaceForLength` due to integer division (6/7). The writeLength function is then called using 1 byte to write the zero length value.
@ou05020 ou05020 requested a review from philpearl January 19, 2020 01:40
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