]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_adelay.c
avcodec: postpone removal of deprecated codec caps
[ffmpeg] / libavfilter / af_adelay.c
index 06e39fa6a423b55edf9042d20c693315c35b16d0..81ff7947f553457b1e9584124ebd94f04fe07a48 100644 (file)
@@ -28,9 +28,9 @@
 #include "internal.h"
 
 typedef struct ChanDelay {
-    int delay;
-    unsigned delay_index;
-    unsigned index;
+    int64_t delay;
+    size_t delay_index;
+    size_t index;
     uint8_t *samples;
 } ChanDelay;
 
@@ -152,10 +152,13 @@ static int config_input(AVFilterLink *inlink)
 
         p = NULL;
 
-        ret = av_sscanf(arg, "%d%c", &d->delay, &type);
+        ret = av_sscanf(arg, "%"SCNd64"%c", &d->delay, &type);
         if (ret != 2 || type != 'S') {
             div = type == 's' ? 1.0 : 1000.0;
-            av_sscanf(arg, "%f", &delay);
+            if (av_sscanf(arg, "%f", &delay) != 1) {
+                av_log(ctx, AV_LOG_ERROR, "Invalid syntax for delay.\n");
+                return AVERROR(EINVAL);
+            }
             d->delay = delay * inlink->sample_rate / div;
         }
 
@@ -165,9 +168,9 @@ static int config_input(AVFilterLink *inlink)
         }
     }
 
-    if (s->all) {
-        for (int j = i + 1; j < s->nb_delays; j++)
-            s->chandelay[j].delay = s->chandelay[i].delay;
+    if (s->all && i) {
+        for (int j = i; j < s->nb_delays; j++)
+            s->chandelay[j].delay = s->chandelay[i-1].delay;
     }
 
     s->padding = s->chandelay[0].delay;
@@ -191,6 +194,11 @@ static int config_input(AVFilterLink *inlink)
         if (!d->delay)
             continue;
 
+        if (d->delay > SIZE_MAX) {
+            av_log(ctx, AV_LOG_ERROR, "Requested delay is too big.\n");
+            return AVERROR(EINVAL);
+        }
+
         d->samples = av_malloc_array(d->delay, s->block_align);
         if (!d->samples)
             return AVERROR(ENOMEM);