mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-11 08:13:06 +00:00
avfilter/scale_eval: reject non-positive output dimensions
When scale filter expressions evaluate to zero or negative output dimensions (e.g. cascaded scale=...:-2 on extreme aspect ratios), ff_scale_adjust_dimensions() only checked for int32 overflow and passed them through, potentially hanging downstream components. Reject them explicitly so the pipeline fails fast. Callers that currently ignore the return value will be updated in the following patches to propagate the error. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
This commit is contained in:
committed by
Jun Zhao
co-authored by
Jun Zhao
parent
c55ab93eef
commit
a45fe72c9d
@@ -18,6 +18,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include "scale_eval.h"
|
||||
#include "libavutil/eval.h"
|
||||
@@ -186,6 +187,13 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink,
|
||||
if ((int32_t)w != w || (int32_t)h != h)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if (w <= 0 || h <= 0) {
|
||||
av_log(inlink->dst, AV_LOG_ERROR,
|
||||
"Rescaled dimensions %"PRId64"x%"PRId64" are invalid, "
|
||||
"output dimensions must be positive.\n", w, h);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
*ret_w = w;
|
||||
*ret_h = h;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user