aboutsummaryrefslogtreecommitdiff
path: root/src/voice/streamer.rs
diff options
context:
space:
mode:
authorMaiddog <[email protected]>2017-08-27 04:17:59 -0500
committeralex <[email protected]>2017-08-27 11:17:59 +0200
commite1a8fe3e9f619fbb94dd54993c8f5d25fd5dc375 (patch)
tree4c6c45cc592505f971c13aee8dfbdd41107a84ce /src/voice/streamer.rs
parentAdd ability to play DCA and Opus files. (#148) (diff)
downloadserenity-e1a8fe3e9f619fbb94dd54993c8f5d25fd5dc375.tar.xz
serenity-e1a8fe3e9f619fbb94dd54993c8f5d25fd5dc375.zip
Prevent malformed opus data from crashing the bot process (#149)
Diffstat (limited to 'src/voice/streamer.rs')
-rw-r--r--src/voice/streamer.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/voice/streamer.rs b/src/voice/streamer.rs
index 5f05879..cf62d27 100644
--- a/src/voice/streamer.rs
+++ b/src/voice/streamer.rs
@@ -48,6 +48,11 @@ impl<R: Read + Send> AudioSource for InputSource<R> {
fn read_opus_frame(&mut self) -> Option<Vec<u8>> {
match self.reader.read_i16::<LittleEndian>() {
Ok(size) => {
+ if size <= 0 {
+ warn!("Invalid opus frame size: {}", size);
+ return None;
+ }
+
let mut frame = Vec::with_capacity(size as usize);
{