swresample/swresample: check for invalid sample rates
authorPaul B Mahol <onemda@gmail.com>
Fri, 24 May 2019 16:04:50 +0000 (18:04 +0200)
committerPaul B Mahol <onemda@gmail.com>
Sun, 26 May 2019 12:43:32 +0000 (14:43 +0200)
libswresample/swresample.c

index 6d28e6a..1ac5ef9 100644 (file)
@@ -164,6 +164,14 @@ av_cold int swr_init(struct SwrContext *s){
         return AVERROR(EINVAL);
     }
 
+    if(s-> in_sample_rate <= 0){
+        av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is invalid\n", s->in_sample_rate);
+        return AVERROR(EINVAL);
+    }
+    if(s->out_sample_rate <= 0){
+        av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is invalid\n", s->out_sample_rate);
+        return AVERROR(EINVAL);
+    }
     s->out.ch_count  = s-> user_out_ch_count;
     s-> in.ch_count  = s->  user_in_ch_count;
     s->used_ch_count = s->user_used_ch_count;