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 /sub | |
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 'sub')
-rw-r--r-- | sub/osd.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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. |