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

Address issue #44 #45

Merged
merged 4 commits into from
Mar 2, 2019
Merged

Conversation

BenSandeen
Copy link
Contributor

This is my first open source PR, so please keep any criticism constructive, thanks!

Copy link
Member

@est31 est31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I'd rather like a solution which uses &codebooks.get() and a if let.

@est31 est31 changed the title Address issue at https://github.com/RustAudio/lewton/issues/44 Address issue #44 Mar 1, 2019
@BenSandeen
Copy link
Contributor Author

Thanks for the PR!

I'd rather like a solution which uses &codebooks.get() and a if let.

Hopefully this is something like what you have in mind.

@est31
Copy link
Member

est31 commented Mar 1, 2019

I had more something like this in mind:

lewton/src/audio.rs

Lines 609 to 613 in 0d13bc4

let vs = if let Some(vs) = vec_v.get_mut(i..(i + entries.len())) {
vs
} else {
break;
};

@est31
Copy link
Member

est31 commented Mar 2, 2019

@BenSandeen want to change it? Then I can merge the PR :)

@BenSandeen
Copy link
Contributor Author

Yep, I'll get to work now, sorry for the delay, I've been busy. Hopefully the third time's the charm! :D

@BenSandeen
Copy link
Contributor Author

BenSandeen commented Mar 2, 2019

And I might as well ask now before pushing another commit: I imagine that, instead of a break like in the else block of that code snippet, you want to return Err(FloorSpecialCase::PacketUndecodable)?
Okay, ignore that while I figure this out, sorry

@est31
Copy link
Member

est31 commented Mar 2, 2019

Yes, that's what I originally imagined.

Actually I think an even better way of fixing the bug would be to reject the entire stream already during header decoding.

For this, please edit the read_floor function in header.rs to check any items in floor0_book_list for whether they are above codebook_cnt. It's mentioned in the spec but we didn't implement it :/.

Sorry for the back & forth, but I think that's what's most compliant with the spec.

@est31
Copy link
Member

est31 commented Mar 2, 2019

Specifically, there is a similar check with codebook_cnt already below in the function.

@BenSandeen
Copy link
Contributor Author

K, I'll take a look at that

@BenSandeen
Copy link
Contributor Author

All right, I undid the previous changes and made the fix in header.rs. If you prefer, I can kill this PR and make a clean PR without the previous changes I've made in the commit history

Copy link
Member

@est31 est31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll merge right away via squashing your commits. In the future you can also check out the command git reset --hard origin/master or git reset --hard upstream/master which will remove any prior commits (needs force push thereafter).

@est31 est31 merged commit 9078060 into RustAudio:master Mar 2, 2019
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.

None yet

2 participants