History

avfilter/scale_eval: Use 64bit, check values in ff_scale_adjust_dimensions()

Found by reviewing CID1513722 Operands don't affect result

Michael Niedermayer committed 2 years ago

Commit ad9df8b1 parent 6db4e322 files · +7 −4Browse files

Showing the changes to libavfilter (2 of 2 files). Show all

Unified · Split

2 files
  1. libavfilter/scale_eval.c +6 −3
  2. libavfilter/scale_eval.h +1 −1
libavfilter/scale_eval.c+6−3
@@ -114,7 +114,7 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, · 113 unmodified lines
114114 int *ret_w, int *ret_h,
115115 int force_original_aspect_ratio, int force_divisible_by)
116116 {
117− int w, h;
117+ int64_t w, h;
118118 int factor_w, factor_h;
119119
120120 w = *ret_w;
@@ -149,9 +149,9 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, · 28 unmodified lines
149149 * unless force_divisible_by is defined as well */
150150 if (force_original_aspect_ratio) {
151151 // Including force_divisible_by here rounds to the nearest multiple of it.
152− int tmp_w = av_rescale(h, inlink->w, inlink->h * (int64_t)force_divisible_by)
152+ int64_t tmp_w = av_rescale(h, inlink->w, inlink->h * (int64_t)force_divisible_by)
153153 * force_divisible_by;
154− int tmp_h = av_rescale(w, inlink->h, inlink->w * (int64_t)force_divisible_by)
154+ int64_t tmp_h = av_rescale(w, inlink->h, inlink->w * (int64_t)force_divisible_by)
155155 * force_divisible_by;
156156
157157 if (force_original_aspect_ratio == 1) {
@@ -173,6 +173,9 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, · 15 unmodified lines
173173 }
174174 }
175175
176+ if ((int32_t)w != w || (int32_t)h != h)
177+ return AVERROR(EINVAL);
178+
176179 *ret_w = w;
177180 *ret_h = h;
178181
libavfilter/scale_eval.h+1−1
@@ -41,7 +41,7 @@ int ff_scale_eval_dimensions(void *ctx, · 40 unmodified lines
4141 * force_original_aspect_ratio is set. force_divisible_by is used only when
4242 * force_original_aspect_ratio is set and must be at least 1.
4343 *
44− * Returns 0.
44+ * Returns negative error code on error or non negative on success
4545 */
4646 int ff_scale_adjust_dimensions(AVFilterLink *inlink,
4747 int *ret_w, int *ret_h,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t