kisielk / og-rek

ogórek is a Go library for encoding and decoding pickles.
MIT License
60 stars 16 forks source link

decoder: Fix thinko in PROTO opcode handling #41

Closed navytux closed 6 years ago

navytux commented 6 years ago

Due to := in

v, err := d.r.ReadByte()

newly declared err was shadowing outside err and thus even though the code intent was to treat all protocols != 2 as ErrInvalidPickleVersion, after leaving the switch err was always =nil and no error was reported.

Fix it by explicitly declaring v and not using := not to shadow err.

We also change the condition for supported protocol version to be in [0, 4] because:

kisielk commented 6 years ago

Ah, shadowing strikes again :/ Good catch, thanks!

navytux commented 6 years ago

Thanks for merging.