summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2018-07-25 20:41:16 +0300
committerTuomas Virtanen <katajakasa@gmail.com>2018-07-25 20:41:16 +0300
commit82cfe8f74c5120afc7340fc99ca30f42f3c7da1b (patch)
treec3676e79bc01c83c34ac3b302faba91f9d1c87d2 /src
parent6f32edb691b929f7770ded23ba5963f3fc3404d1 (diff)
Check errors on avcontext allocation
Diffstat (limited to 'src')
-rw-r--r--src/internal/kitdecoder.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/internal/kitdecoder.c b/src/internal/kitdecoder.c
index e2d0a25..112be8e 100644
--- a/src/internal/kitdecoder.c
+++ b/src/internal/kitdecoder.c
@@ -47,11 +47,17 @@ Kit_Decoder* Kit_CreateDecoder(const Kit_Source *src, int stream_index,
// Allocate a context for the codec
codec_ctx = avcodec_alloc_context3(codec);
- if(avcodec_copy_context(codec_ctx, format_ctx->streams[stream_index]->codec) != 0) {
- Kit_SetError("Unable to copy audio codec context for stream %d", stream_index);
+ if(codec_ctx == NULL) {
+ Kit_SetError("Unable to allocate codec context for stream %d", stream_index);
goto exit_1;
}
+ // Copy context from stream to target codec context
+ if(avcodec_copy_context(codec_ctx, format_ctx->streams[stream_index]->codec) != 0) {
+ Kit_SetError("Unable to copy codec context for stream %d", stream_index);
+ goto exit_2;
+ }
+
// Set thread count
codec_ctx->thread_count = thread_count;
codec_ctx->thread_type = FF_THREAD_SLICE;