diff options
author | wm4 <wm4@nowhere> | 2018-05-20 13:38:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:35 +0200 |
commit | 246a828c262eda553420c8b861c2a01cd89af74a (patch) | |
tree | d8892a10b8239d9f12c2649e62e4dc367c1ed52b /options | |
parent | 4e9166f22d9e72100d11b5f7e0798d84ece4d2ac (diff) | |
download | mpv-246a828c262eda553420c8b861c2a01cd89af74a.tar.bz2 mpv-246a828c262eda553420c8b861c2a01cd89af74a.tar.xz |
m_config: check for int16_t offset overflow
For some reason shadow_offset is a int16_t variable (to save some space
or something), which means the static part of the entire option list
must be below 32KB. This is fine, but still add a check against
overflows. (Currently it's 3.6KB. This does not include dynamic
allocations like strings.)
Diffstat (limited to 'options')
-rw-r--r-- | options/m_config.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/options/m_config.c b/options/m_config.c index 2f63cf5363..aa0018314d 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -525,7 +525,9 @@ static void m_config_add_option(struct m_config *config, // The required alignment is unknown, so go with the maximum C // could require. Slightly wasteful, but not that much. int align = (size - config->shadow_size % size) % size; - co.shadow_offset = config->shadow_size + align; + int offset = config->shadow_size + align; + assert(offset <= INT16_MAX); + co.shadow_offset = offset; config->shadow_size = co.shadow_offset + size; } |