# HG changeset patch # User reimar # Date 1351617268 0 # Node ID 9b921155e030855f5b3ea19b485a86c35f8f7923 # Parent 8528f4b70dff7328bb49e086bcea744c6bf32dd0 Move check for NULL to before the pointer is used. diff -r 8528f4b70dff -r 9b921155e030 sub/av_sub.c --- a/sub/av_sub.c Tue Oct 30 17:09:14 2012 +0000 +++ b/sub/av_sub.c Tue Oct 30 17:14:28 2012 +0000 @@ -110,10 +110,15 @@ AVCodec *sub_codec; init_avcodec(); ctx = avcodec_alloc_context3(NULL); + if (!ctx) { + mp_msg(MSGT_SUBREADER, MSGL_FATAL, + "Could not allocate subtitle decoder context\n"); + return -1; + } ctx->extradata_size = sh->extradata_len; ctx->extradata = sh->extradata; sub_codec = avcodec_find_decoder(cid); - if (!ctx || !sub_codec || avcodec_open2(ctx, sub_codec, NULL) < 0) { + if (!sub_codec || avcodec_open2(ctx, sub_codec, NULL) < 0) { mp_msg(MSGT_SUBREADER, MSGL_FATAL, "Could not open subtitle decoder\n"); av_freep(&ctx);