Changeset 9fd74d5 in mainline


Ignore:
Timestamp:
2025-11-09T16:20:43Z (3 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
a4301f1
Parents:
e6b4d2d
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-11-09 16:19:21)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-11-09 16:20:43)
Message:

libtermui: Ensure fully consistent history state when evicting old data

Fixes bug #890

Location:
uspace/lib/termui/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/termui/src/history.c

    re6b4d2d r9fd74d5  
    126126
    127127#define _history_check(history) do { \
    128         assert(history->lines.head < history->lines.buf_len); \
    129         assert(history->lines.tail < history->lines.buf_len); \
     128        assert(history->lines.head < history->lines.buf_len || history->lines.head == 0); \
     129        assert(history->lines.tail < history->lines.buf_len || history->lines.tail == 0); \
    130130        assert(history->cells.tail_top <= history->cells.head_offset); \
    131131        assert(history->cells.head_offset <= history->cells.head_top); \
     
    298298        if (lines->tail >= lines->buf_len)
    299299                lines->tail = 0;
     300
     301        if (viewport_inactive) {
     302            /* Ensure consistent state so asserts don't trigger inside _evict_oldest_line(). */
     303            history->viewport_top = lines->tail;
     304        }
    300305
    301306        if (lines->tail == lines->head)
  • uspace/lib/termui/src/history.h

    re6b4d2d r9fd74d5  
    6666};
    6767
     68/* History consists of two circular buffers.
     69 * The cell buffer is a linear array of character cells.
     70 * The line buffer contains offsets into the cell buffer, and segments it into logical lines.
     71 * Both of these buffers have a maximum size, so history is limited both by maximum number
     72 * of characters, and maximum number of lines.  */
    6873struct history {
    6974        size_t viewport_top;
Note: See TracChangeset for help on using the changeset viewer.