Ticket #4843: libs_libmythdvdnav_searching.c-bad-test-for-for-loop.3.patch

File libs_libmythdvdnav_searching.c-bad-test-for-for-loop.3.patch, 1.2 KB (added by Erik Hovland <erik@…>, 16 years ago)

Another array needed to be index as i-1

  • libs/libmythdvdnav/searching.c

    stime has only 19 items. So the for loop should stop at 18, not 19.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythdvdnav/searching.c |   10 +++++-----
     1 files changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/libs/libmythdvdnav/searching.c b/libs/libmythdvdnav/searching.c
    index 4667d3f..ca4c0c0 100644
    a b dvdnav_status_t dvdnav_time_search_within_cell(dvdnav_t *this, 
    690690  {
    691691    dsi = dvdnav_get_current_nav_dsi(this);
    692692    if (length > 0) {
    693       for (i = 1; i <= 19; i++) {
    694         if (stime[i]/2.0 <= length/2.0) {
    695           offset = dsi->vobu_sri.fwda[i];
     693      for (i = 1; i < 20; i++) {
     694        if (stime[i-1]/2.0 <= length/2.0) {
     695          offset = dsi->vobu_sri.fwda[i-1];
    696696          if (offset >> 31) {
    697697            new_vobu = cur_vobu + (offset & 0xffff);
    698698          } else {
    dvdnav_status_t dvdnav_time_search_within_cell(dvdnav_t *this, 
    708708        }
    709709      }
    710710    } else {
    711       for (i = 1; i <= 19; i++) {
    712         if (stime[18 - i]/2.0 >= abs(length)/2.0)
     711      for (i = 1; i < 20; i++) {
     712        if (stime[19 - i]/2.0 >= abs(length)/2.0)
    713713        {
    714714          offset = dsi->vobu_sri.bwda[i];
    715715          if (offset >> 31) {