diff options
author | Ben Boeckel <mathstuf@gmail.com> | 2014-09-14 14:35:56 -0400 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-14 21:07:30 +0200 |
commit | 3f6212cd8d2d8a86bb913d00463620cd2abbc8d9 (patch) | |
tree | 77523330edb4cd59b1930fb988a50c4231099fdd /player | |
parent | e0b4daf3ad240ecf70af73c13b6ca9b1062a507f (diff) | |
download | mpv-3f6212cd8d2d8a86bb913d00463620cd2abbc8d9.tar.bz2 mpv-3f6212cd8d2d8a86bb913d00463620cd2abbc8d9.tar.xz |
sanitizer: avoid divide-by-zero instances
Merges pull request #1094, with some minor changes. mpv expects IEEE,
and IEEE allows divisions by 0 for floats, so these shouldn't actually
be a problem, but do it anyway for the sake of clang.
Signed-off-by: wm4 <wm4@nowhere>
Diffstat (limited to 'player')
-rw-r--r-- | player/lua.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/player/lua.c b/player/lua.c index ddcd8acc50..06d61f4c83 100644 --- a/player/lua.c +++ b/player/lua.c @@ -892,7 +892,7 @@ static int script_get_screen_size(lua_State *L) struct MPContext *mpctx = get_mpctx(L); struct mp_osd_res vo_res = osd_get_vo_res(mpctx->osd, OSDTYPE_EXTERNAL); double aspect = 1.0 * vo_res.w / MPMAX(vo_res.h, 1) / - vo_res.display_par; + (vo_res.display_par ? vo_res.display_par : 1); lua_pushnumber(L, vo_res.w); lua_pushnumber(L, vo_res.h); lua_pushnumber(L, aspect); @@ -978,10 +978,10 @@ static int script_input_set_section_mouse_area(lua_State *L) osd_object_get_scale_factor(mpctx->osd, OSDTYPE_EXTERNAL, &sw, &sh); char *section = (char *)luaL_checkstring(L, 1); - int x0 = luaL_checkinteger(L, 2) / sw; - int y0 = luaL_checkinteger(L, 3) / sh; - int x1 = luaL_checkinteger(L, 4) / sw; - int y1 = luaL_checkinteger(L, 5) / sh; + int x0 = sw ? luaL_checkinteger(L, 2) / sw : 0; + int y0 = sh ? luaL_checkinteger(L, 3) / sh : 0; + int x1 = sw ? luaL_checkinteger(L, 4) / sw : 0; + int y1 = sh ? luaL_checkinteger(L, 5) / sh : 0; mp_input_set_section_mouse_area(mpctx->input, section, x0, y0, x1, y1); return 0; } |