From de0f9b9f2d12f59e31220cf26e3a258e126987c7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 16 Dec 2019 01:52:52 +0100 Subject: 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. --- options/m_option.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'options/m_option.c') 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); -- cgit v1.2.3