New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sfixed64 are smaller by a factor of 2 #692

Closed
tomergg opened this Issue Mar 1, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@tomergg

tomergg commented Mar 1, 2017

protobuf.js version: v6.6.4

When deserializing sfixed64 values, the Long object returned contains data that is smaller by a factor of 2.
I've compared v5.0.2 results with v6.6.4.

  • Identical base 64 input
  • output of Long values is different by a factor of 2

v6.6.4

const pbEntity = pbRoot.lookup(schema);
const buffer = Buffer.from(base64Data, 'base64');
const entity = pbEntity.decode(buffer).toObject({ bytes: String, enums: String, arrays: true });

v5.0.2

const entity = protoBufBuilder.build(schema).decode(base64Data).toRaw(true);

When I removed the zzDecode call, I got correct results:

function read_sfixed64_long() {
    return readFixed64.call(this).toLong();
}

instead of:

function read_sfixed64_long() {
    return readFixed64.call(this).zzDecode().toLong();
}

I think that the implementation might need to be identical to fixed64.
If needed, I can write some code to repro the problem in isolation.

@tomergg tomergg changed the title from signed 64 bit integers are smaller by a factor of 2 to sfixed64 are smaller by a factor of 2 Mar 1, 2017

@dcodeIO dcodeIO added the bug label Mar 1, 2017

dcodeIO added a commit that referenced this issue Mar 1, 2017

@tomergg

This comment has been minimized.

tomergg commented Mar 1, 2017

Thank you for the quick fix.
If I may ask, when are you planning on releasing v6.6.5 to npm?

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Mar 2, 2017

Now on npm! Feel free to reopen if there are still any issues.

@dcodeIO dcodeIO closed this Mar 2, 2017

@tomergg

This comment has been minimized.

tomergg commented Mar 2, 2017

@dcodeIO, thank you!

edit:
works like magic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment