Ticket #4662: fix-unsigned-logic-in-dvdnav-searching.patch

File fix-unsigned-logic-in-dvdnav-searching.patch, 945 bytes (added by Erik Hovland <erik@…>, 18 years ago)

changes conditional on seek to actually work

  • libs/libmythdvdnav/searching.c

    The two variables offset and length in function dvdnav_sector_search
    
    From: Erik Hovland <erik@hovland.org>
    
    are both unsigned types. So if you subtract one from the other
    and test for less then zero it will have no effect. This is
    because unsigned values will underflow and always be
    non-negative. This patch changes the test so it will work properly.
    ---
    
     libs/libmythdvdnav/searching.c |    2 +-
     1 files changed, 1 insertions(+), 1 deletions(-)
    
    diff --git a/libs/libmythdvdnav/searching.c b/libs/libmythdvdnav/searching.c
    index 4769bda..1524e9b 100644
    a b dvdnav_status_t dvdnav_sector_search(dvdnav_t *this,  
    259259    target += offset;
    260260    break;
    261261   case SEEK_END:
    262     if(length - offset < 0) {
     262    if(offset > length) {
    263263      printerr("Request to seek before start.");
    264264      pthread_mutex_unlock(&this->vm_lock);
    265265      return DVDNAV_STATUS_ERR;