lavfi/overlay: fix crash in case of invalid expression

This commit is contained in:
Stefano Sabatini 2013-04-11 23:54:24 +02:00
parent ed2c827575
commit aff6cebb41
1 changed files with 9 additions and 4 deletions

View File

@ -170,18 +170,23 @@ static void eval_expr(AVFilterContext *ctx, enum EvalTarget eval_tgt)
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx) static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
{ {
int ret; int ret;
AVExpr *old = NULL;
if (*pexpr) if (*pexpr)
av_expr_free(*pexpr); old = *pexpr;
*pexpr = NULL;
ret = av_expr_parse(pexpr, expr, var_names, ret = av_expr_parse(pexpr, expr, var_names,
NULL, NULL, NULL, NULL, 0, log_ctx); NULL, NULL, NULL, NULL, 0, log_ctx);
if (ret < 0) if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR, av_log(log_ctx, AV_LOG_ERROR,
"Error when evaluating the expression '%s'\n", expr); "Error when evaluating the expression '%s'\n", expr);
*pexpr = old;
return ret; return ret;
} }
av_expr_free(old);
return 0;
}
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
char *res, int res_len, int flags) char *res, int res_len, int flags)
{ {