[FFmpeg-devel] [PATCH v3] libavfilter/formats: Fix parsing of channel specifications with a trailing 'c'.

Simon Thelen ffmpeg-dev at c-14.de
Sat Jun 20 18:52:50 CEST 2015


Signed-off-by: Simon Thelen <ffmpeg-dev at c-14.de>
---
:100644 100644 2451bf7... 8758b3d... M	libavfilter/formats.c
 libavfilter/formats.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 2451bf7..8758b3d 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -637,23 +637,20 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg,
                             void *log_ctx)
 {
     char *tail;
-    int64_t chlayout, count;
+    int64_t chlayout;
 
-    if (nret) {
-        count = strtol(arg, &tail, 10);
-        if (*tail == 'c' && !tail[1] && count > 0 && count < 63) {
-            *nret = count;
-            *ret = 0;
-            return 0;
-        }
-    }
     chlayout = av_get_channel_layout(arg);
     if (chlayout == 0) {
         chlayout = strtol(arg, &tail, 10);
-        if (*tail || chlayout == 0) {
+        if (!(*tail == '\0' || *tail == 'c' && *(tail + 1) == '\0') || chlayout <= 0 || chlayout > 63) {
             av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg);
             return AVERROR(EINVAL);
         }
+        if (nret) {
+            *nret = chlayout;
+            *ret = 0;
+            return 0;
+        }
     }
     *ret = chlayout;
     if (nret)
-- 
2.4.3



More information about the ffmpeg-devel mailing list