summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-09-18 13:28:59 +0200
committerDudemanguy <random342@airmail.cc>2023-09-20 19:08:19 +0000
commit20e584f60bdac96ed915151cf0f92d8282c0a0b3 (patch)
tree4e5185bf2eba0657534324936ff172508222a29f /options/m_option.c
parent582c7556c697a1efd24c9e71c91ef8c5a77acd0d (diff)
downloadmpv-20e584f60bdac96ed915151cf0f92d8282c0a0b3.tar.bz2
mpv-20e584f60bdac96ed915151cf0f92d8282c0a0b3.tar.xz
options: make video-crop validation more strict
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 01f4da9195..892c38b422 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2393,8 +2393,10 @@ void m_rect_apply(struct mp_rect *rc, int w, int h, struct m_geometry *gm)
rc->x1 = w - rc->x0;
if (!gm->wh_valid || rc->y1 == 0 || rc->y1 == INT_MIN)
rc->y1 = h - rc->y0;
- rc->x1 += rc->x0;
- rc->y1 += rc->y0;
+ if (gm->wh_valid && (gm->w || gm->h))
+ rc->x1 += rc->x0;
+ if (gm->wh_valid && (gm->w || gm->h))
+ rc->y1 += rc->y0;
}
static int parse_rect(struct mp_log *log, const m_option_t *opt,
@@ -2408,12 +2410,12 @@ static int parse_rect(struct mp_log *log, const m_option_t *opt,
if (!parse_geometry_str(&gm, param))
goto exit;
- if (gm.x_sign || gm.y_sign || gm.ws ||
- (gm.wh_valid && (gm.w < 0 || gm.h < 0)) ||
- (gm.xy_valid && (gm.x < 0 || gm.y < 0)))
- {
+ bool invalid = gm.x_sign || gm.y_sign || gm.ws;
+ invalid |= gm.wh_valid && (gm.w < 0 || gm.h < 0);
+ invalid |= gm.wh_valid && !gm.xy_valid && gm.w <= 0 && gm.h <= 0;
+
+ if (invalid)
goto exit;
- }
if (dst)
*((struct m_geometry *)dst) = gm;