diff eval.c @ 946:f05ed9190133 libavutil

Make av_parse_expr() fail if there are trailing chars at the end of the provided expression. Allow detection of mistyped expressions.
author stefano
date Wed, 16 Jun 2010 18:27:55 +0000
parents 4059de4c9f90
children 34a4ee230079
line wrap: on
line diff
--- a/eval.c	Wed Jun 16 18:27:46 2010 +0000
+++ b/eval.c	Wed Jun 16 18:27:55 2010 +0000
@@ -448,6 +448,7 @@
     AVExpr *e = NULL;
     char *w = av_malloc(strlen(s) + 1);
     char *wp = w;
+    const char *s0 = s;
     int ret = 0;
 
     if (!w)
@@ -470,6 +471,11 @@
 
     if ((ret = parse_expr(&e, &p)) < 0)
         goto end;
+    if (*p.s) {
+        av_log(&p, AV_LOG_ERROR, "Invalid chars '%s' at the end of expression '%s'\n", p.s, s0);
+        ret = AVERROR(EINVAL);
+        goto end;
+    }
     if (!verify_expr(e)) {
         av_free_expr(e);
         ret = AVERROR(EINVAL);