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 --- sub/osd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sub/osd.c') diff --git a/sub/osd.c b/sub/osd.c index e88df98afe..85d951b3b7 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -428,9 +428,11 @@ void osd_object_get_scale_factor(struct osd_state *osd, int obj, int nw, nh; osd_object_get_resolution(osd, obj, &nw, &nh); pthread_mutex_lock(&osd->lock); - *sw = nw / (double)osd->objs[obj]->vo_res.w; - *sh = nh / (double)osd->objs[obj]->vo_res.h; + int vow = osd->objs[obj]->vo_res.w; + int voh = osd->objs[obj]->vo_res.h; pthread_mutex_unlock(&osd->lock); + *sw = vow ? nw / (double)vow : 0; + *sh = voh ? nh / (double)voh : 0; } // Turn *x and *y, which are given in OSD coordinates, to video coordinates. -- cgit v1.2.3