From 2dfe2fb22c332e15f9a45d5a3ad548d6a602ceda Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 18 Dec 2014 22:13:01 +0100 Subject: decoder/ffmpeg: fix crash on out-of-memory Fixes regression by commit 7c8038e --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index e7f2ebfb0..60c49800d 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -340,15 +340,19 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is, break; } - uint8_t *output_buffer; + uint8_t *output_buffer = nullptr; int audio_size = 0; if (got_frame) { audio_size = copy_interleave_frame(codec_context, frame, &output_buffer, buffer, buffer_size); - if (audio_size < 0) - len = audio_size; + if (audio_size < 0) { + /* this must be a serious error, + e.g. OOM */ + LogFfmpegError(audio_size); + return DecoderCommand::STOP; + } } packet2.data += len; -- cgit v1.2.3