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

Add Music::from_bytes() function #704

Merged
merged 3 commits into from
Sep 10, 2017
Merged

Add Music::from_bytes() function #704

merged 3 commits into from
Sep 10, 2017

Conversation

Flaise
Copy link
Contributor

@Flaise Flaise commented Sep 10, 2017

This is a solution to issue #696.

@@ -790,6 +790,28 @@ impl<'a> Music<'a> {
}
}

/// Load music from a byte buffer.
pub fn from_bytes(buf: &[u8]) -> Result<Music<'static>, String> {
Copy link
Member

Choose a reason for hiding this comment

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

This is pretty unsafe, if the &[u8] comes from a Vec that gets destroyed right afterwards, this will probably crash, unless I'm missing something.

Please replace that by &'static [u8], and change the fn name to from_static_bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right; I tried that and it crashed immediately.

@Cobrand
Copy link
Member

Cobrand commented Sep 10, 2017

Would you mind adding an entry for that in the changelog for 0.31 as well?

@Cobrand Cobrand merged commit b52bd54 into Rust-SDL2:master Sep 10, 2017
@Cobrand
Copy link
Member

Cobrand commented Sep 10, 2017

Thanks!

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