[libdvdnav-devel] [Git][videolan/libdvdnav][master] Avoid division-by-zero when tmap search returns two tmap entries
Jean-Baptiste Kempf
gitlab at videolan.org
Sat Aug 10 12:58:04 CEST 2019
Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdnav
Commits:
320b88d3 by John Sullivan at 2019-08-09T12:33:49Z
Avoid division-by-zero when tmap search returns two tmap entries
with the same vobu_idx (which can happen at the end of a title).
- - - - -
1 changed file:
- src/searching.c
Changes:
=====================================
src/searching.c
=====================================
@@ -1094,8 +1094,14 @@ static int32_t dvdnav_tmap_calc_time_for_tmap_entry(dvdnav_jump_args_t *args,
}
/* calc position of cell relative to lo */
- vobu_pct = ((pos->vobu_idx - lo->vobu_idx) * 1000)
- / ( hi->vobu_idx - lo->vobu_idx);
+ if (hi->vobu_idx == lo->vobu_idx) {
+ /* We are at the very end - pos should also equal lo so force that
+ * rather than hit the divide-by-zero. */
+ vobu_pct = 0;
+ } else {
+ vobu_pct = ((pos->vobu_idx - lo->vobu_idx) * 1000)
+ / ( hi->vobu_idx - lo->vobu_idx);
+ }
if (vobu_pct < 0 || vobu_pct > 1000) {
fprintf(MSG_OUT, "vobu_pct must be between 0 and 1000");
return 0;
View it on GitLab: https://code.videolan.org/videolan/libdvdnav/commit/320b88d3489a8dc03c88252fededd8db1bb7964e
--
View it on GitLab: https://code.videolan.org/videolan/libdvdnav/commit/320b88d3489a8dc03c88252fededd8db1bb7964e
You're receiving this email because of your account on code.videolan.org.
More information about the libdvdnav-devel
mailing list