libavutil/channel_layout: Check strtol*() for failure
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 5 Nov 2015 18:24:33 +0000 (19:24 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 5 Nov 2015 18:28:19 +0000 (19:28 +0100)
Fixes assertion failure
Fixes: 4f5814bb15d2dda6fc18ef9791b13816/signal_sigabrt_7ffff6ae7cc9_65_7209d160d168b76f311be6cd64a548eb.wv

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/channel_layout.c

index a59ba46..601c7e6 100644 (file)
@@ -122,13 +122,16 @@ static uint64_t get_channel_layout_single(const char *name, int name_len)
             strlen(channel_names[i].name) == name_len &&
             !memcmp(channel_names[i].name, name, name_len))
             return (int64_t)1 << i;
+
+    errno = 0;
     i = strtol(name, &end, 10);
 
-    if ((end + 1 - name == name_len && *end  == 'c'))
+    if (!errno && (end + 1 - name == name_len && *end  == 'c'))
         return av_get_default_channel_layout(i);
 
+    errno = 0;
     layout = strtoll(name, &end, 0);
-    if (end - name == name_len)
+    if (!errno && end - name == name_len)
         return FFMAX(layout, 0);
     return 0;
 }