protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

Fix encoding of int64/bool keys of maps in encoder

Open reebalazs opened this issue 3 years ago • 1 comments

Fixes #1652 .

The int64 writer cannot handle the hash directly, because it interprets it as a string representation of a Long number, instead of a hash.

This is obviously wrong, because the input at this point always contains the longbit hashes already. So the int64() writer fails inevitably.

I believe that the simplest solution is: Explicit conversion from hash to long is needed before writing.

Again (just like with the other PR I submitted) I believe that the tests are missing for the generated encode/decode functions. If there were such tests, it would be fairly straightforward to write a test case that exercises this problem, and proves that the fix, in fact, works.

reebalazs avatar Sep 17 '21 08:09 reebalazs

Exactly same case with a bool key type. Fix extended to cover this case as well.

reebalazs avatar Sep 17 '21 09:09 reebalazs