swr-test: check pointers before use
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 16 Oct 2012 17:38:08 +0000 (19:38 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 16 Oct 2012 17:39:25 +0000 (19:39 +0200)
Fixes: CID733807, CID733806
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/swresample-test.c

index 4a0728c..7260a76 100644 (file)
@@ -304,14 +304,18 @@ int main(int argc, char **argv){
         backw_ctx = swr_alloc_set_opts(backw_ctx, in_ch_layout,  in_sample_fmt,             in_sample_rate,
                                                     out_ch_layout, out_sample_fmt, out_sample_rate,
                                         0, 0);
+        if(!forw_ctx) {
+            fprintf(stderr, "Failed to init forw_cts\n");
+            return 1;
+        }
+        if(!backw_ctx) {
+            fprintf(stderr, "Failed to init backw_ctx\n");
+            return 1;
+        }
         if(swr_init( forw_ctx) < 0)
             fprintf(stderr, "swr_init(->) failed\n");
         if(swr_init(backw_ctx) < 0)
             fprintf(stderr, "swr_init(<-) failed\n");
-        if(!forw_ctx)
-            fprintf(stderr, "Failed to init forw_cts\n");
-        if(!backw_ctx)
-            fprintf(stderr, "Failed to init backw_ctx\n");
                 //FIXME test planar
         setup_array(ain , array_in ,  in_sample_fmt,   SAMPLES);
         setup_array(amid, array_mid, out_sample_fmt, 3*SAMPLES);