Closed pyrote closed 2 years ago
Thank you, seems that even the less usual strings from the utf-8 sampler didn't contain anything that triggered this bug. I'll publish 1.1 with the fix. Also added one of your examples to the tests, though it's not a kind of library I'll probably be updating frequently enough for this to reoccur somehow :)
EDIT: v1.1 is published. Also, please ignore CI failing for 79fe64914ba27586f3cae6c027425472c869d802 - I forgot it checked for style and didn't run deno fmt
before commiting. Fixed it before release :)
Glad to help. It was a total edge case that showed up maybe 50/10000 runs when encoding SHA sums.
If you try to encode certain Uint8Array's, encode will return undefined because the queue variable goes negative.
Will encode to
6o#DGft<cVD.N)9AaSundefinedundefined
Or with a hex string,
Will encode to
Yelt,de)Uz)OYvMA0kundefinedundefined
The fix is to change (numbits >= 13) to (numbits > 13) then queue will not go negative and return undefined values.