changeset 35199:9b921155e030

Move check for NULL to before the pointer is used.
author reimar
date Tue, 30 Oct 2012 17:14:28 +0000
parents 8528f4b70dff
children 4078c5a09d8e
files sub/av_sub.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);