Skip to content
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

fix for decodeDict #3

Merged
merged 2 commits into from
Aug 19, 2012
Merged

fix for decodeDict #3

merged 2 commits into from
Aug 19, 2012

Conversation

cbodley
Copy link
Contributor

@cbodley cbodley commented Aug 19, 2012

Using the following structs:

type TrackerPeer struct {
        PeerId string           `bencode:"peer id"`
        Ip string               `bencode:"ip"`
        Port int                `bencode:"port"`
}
type TrackerResponse struct {
        Interval int            `bencode:"interval"`
        Peers []TrackerPeer     `bencode:"peers"`
}

I was able to encode TrackerResponse successfully, but got an error on decode. I spent some time debugging, and eventually found the bug in decodeDict().

while tracking down a bug in decoding of dicts, i added test cases for
encode/decode of lists of dict, and dicts of list.  the failing test
case attempts to decode into []map[string]int
this fixes the test case that attempts to decode into []map[string]int

decodeDict() was calling l.nextToken() to consume the dictEndType token,
but it was already consumed by 'key := l.nextToken()' above
zeebo added a commit that referenced this pull request Aug 19, 2012
@zeebo zeebo merged commit cc05ebe into zeebo:master Aug 19, 2012
@zeebo
Copy link
Owner

zeebo commented Aug 19, 2012

Thanks so much for finding this stuff and the excellent reports/tests/patches.

@cbodley
Copy link
Contributor Author

cbodley commented Aug 19, 2012

Happy to help!

@zeebo
Copy link
Owner

zeebo commented Jul 11, 2013

Do you mind if I license this library under the MIT (http://opensource.org/licenses/MIT) license? If so, how would you like to be attributed in the AUTHORS?

@cbodley
Copy link
Contributor Author

cbodley commented Jul 11, 2013

By all means.
Signed-off-by: Casey Bodley cbodley@gmail.com

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.

2 participants