Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset bdb2a72f in mainline


Ignore:
Timestamp:
2021-10-19T20:01:48Z (13 months ago)
Author:
Jiri Svoboda <jiri@…>
Children:
08d5f8b
Parents:
9468680
Message:

Make sure page is not beyond end of list

Need to correct max_idx correctly for short lists (was getting a
negative number and putting it to a size_t). Need to prevent
page going beyond end of list when moving up a dir and seeking
to the entry of directory we just exited (unless the list is short).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nav/panel.c

    r9468680 rbdb2a72f  
    523523        char *olddn;
    524524        size_t pg_size;
     525        size_t max_idx;
    525526        size_t i;
    526527        errno_t rc;
     
    617618                                --panel->page_idx;
    618619                        }
     620
     621                        /* Make sure page is not beyond the end if possible */
     622                        if (panel->entries_cnt > pg_size)
     623                                max_idx = panel->entries_cnt - pg_size;
     624                        else
     625                                max_idx = 0;
     626
     627                        while (panel->page_idx > 0 && panel->page_idx > max_idx) {
     628                                prev = panel_prev(panel->page);
     629                                if (prev == NULL)
     630                                        break;
     631
     632                                panel->page = prev;
     633                                --panel->page_idx;
     634                        }
    619635                }
    620636        }
     
    948964        old_cursor = panel->cursor;
    949965        old_idx = panel->cursor_idx;
    950         max_idx = panel->entries_cnt - rows;
     966
     967        if (panel->entries_cnt > rows)
     968                max_idx = panel->entries_cnt - rows;
     969        else
     970                max_idx = 0;
    951971
    952972        /* Move page by rows entries down (if possible) */
Note: See TracChangeset for help on using the changeset viewer.