summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-16 01:52:52 +0100
committerwm4 <wm4@nowhere>2019-12-16 01:52:52 +0100
commitde0f9b9f2d12f59e31220cf26e3a258e126987c7 (patch)
tree8abca9e308026a3ed20e926b4d9f739b91449ad9 /options/m_option.c
parentaa5f234b439f69c66e66fa033f443edc3055f185 (diff)
downloadmpv-de0f9b9f2d12f59e31220cf26e3a258e126987c7.tar.bz2
mpv-de0f9b9f2d12f59e31220cf26e3a258e126987c7.tar.xz
m_option: clamp integer before adding a value
This is for the previous commit, and should affect behavior with the special M_PROPERTY_GET_CONSTRICTED_TYPE mechanism only. The effect is that cycling the "edition" property, if the option is set to "auto", will change to the second edition instead of the first. Normally, option values must always be within their range, so this should not affect anything else. M_PROPERTY_GET_CONSTRICTED_TYPE is sort-of fine with this kind of behavior. If this affects any other M_PROPERTY_GET_CONSTRICTED_TYPE users neqatively, I will revert the change.
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 1f6d8e800b..0fb13333d4 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -282,6 +282,8 @@ static void add_int64(const m_option_t *opt, void *val, double add, bool wrap)
{
int64_t v = *(int64_t *)val;
+ clamp_int64(opt, &v);
+
v = v + add;
bool is64 = opt->type->size == sizeof(int64_t);