From 3f6212cd8d2d8a86bb913d00463620cd2abbc8d9 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 14 Sep 2014 14:35:56 -0400 Subject: 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 --- player/lua.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'player') 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; } -- cgit v1.2.3