[FFmpeg-cvslog] lavfi/sendcmd: improve error reporting and robustness in case of missing commands

Stefano Sabatini git at videolan.org
Mon Mar 16 10:56:12 CET 2015


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Mon Mar 16 10:41:19 2015 +0100| [83ee820a1678937ab8343f2766e9662ef9fd420f] | committer: Stefano Sabatini

lavfi/sendcmd: improve error reporting and robustness in case of missing commands

In particular, fix crash with -vf sendcmd, when no arguments are provided.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83ee820a1678937ab8343f2766e9662ef9fd420f
---

 libavfilter/f_sendcmd.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
index e1e649c..7cb958b 100644
--- a/libavfilter/f_sendcmd.c
+++ b/libavfilter/f_sendcmd.c
@@ -318,6 +318,9 @@ static int parse_intervals(Interval **intervals, int *nb_intervals,
     *intervals = NULL;
     *nb_intervals = 0;
 
+    if (!buf)
+        return 0;
+
     while (1) {
         Interval interval;
 
@@ -373,9 +376,9 @@ static av_cold int init(AVFilterContext *ctx)
     SendCmdContext *sendcmd = ctx->priv;
     int ret, i, j;
 
-    if (sendcmd->commands_filename && sendcmd->commands_str) {
+    if ((!!sendcmd->commands_filename + !!sendcmd->commands_str) != 1) {
         av_log(ctx, AV_LOG_ERROR,
-               "Only one of the filename or commands options must be specified\n");
+               "One and only one of the filename or commands options must be specified\n");
         return AVERROR(EINVAL);
     }
 
@@ -404,7 +407,7 @@ static av_cold int init(AVFilterContext *ctx)
         return ret;
 
     if (sendcmd->nb_intervals == 0) {
-        av_log(ctx, AV_LOG_ERROR, "No commands\n");
+        av_log(ctx, AV_LOG_ERROR, "No commands were specified\n");
         return AVERROR(EINVAL);
     }
 



More information about the ffmpeg-cvslog mailing list