From 0444ddab72c195d91e422ac659594e6d81fbf938 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 20 Jun 2014 10:04:25 +0100 Subject: [PATCH] Don't allow _decoded_audio to grow to very large sizes during seek. --- src/lib/audio_decoder.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 4a543cea9..2c0388fc3 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -132,7 +132,16 @@ AudioDecoder::audio (shared_ptr data, ContentTime time) assert (_audio_position.get() >= (_decoded_audio.frame + _decoded_audio.audio->frames())); /* Resize _decoded_audio to fit the new data */ - int const new_size = _audio_position.get() + data->frames() - _decoded_audio.frame; + int new_size = 0; + if (_decoded_audio.audio->frames() == 0) { + /* There's nothing in there, so just store the new data */ + new_size = data->frames (); + _decoded_audio.frame = _audio_position.get (); + } else { + /* Otherwise we need to extend _decoded_audio to include the new stuff */ + new_size = _audio_position.get() + data->frames() - _decoded_audio.frame; + } + _decoded_audio.audio->ensure_size (new_size); _decoded_audio.audio->set_frames (new_size); -- 2.30.2