wustho / epy

CLI Ebook (epub2, epub3, fb2, mobi) Reader
GNU General Public License v3.0
971 stars 53 forks source link

_curses.error: chgat() returned ERR when searching for a specific string #109

Open jasonblewis opened 1 month ago

jasonblewis commented 1 month ago

Hi,

In a certain ebook, when I search for the word "abuse" it causes epy to crash. Searching for other strings does not cause it to crash.

Traceback (most recent call last):
  File "/home/jason/.local/bin/epy", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/jason/.local/pipx/venvs/epy-reader/lib/python3.11/site-packages/epy_reader/__main__.py", line 18, in main
    filepath = curses.wrapper(reader.start_reading, filepath)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jason/.local/pipx/venvs/epy-reader/lib/python3.11/site-packages/epy_reader/reader.py", line 1600, in start_reading
    reading_state_or_ebook = reader.read(reading_state)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jason/.local/pipx/venvs/epy-reader/lib/python3.11/site-packages/epy_reader/reader.py", line 877, in read
    board.write(reading_state.row)
  File "/home/jason/.local/pipx/venvs/epy-reader/lib/python3.11/site-packages/epy_reader/board.py", line 109, in write
    self.render_styles(row, self.default_style, bottom_padding)
  File "/home/jason/.local/pipx/venvs/epy-reader/lib/python3.11/site-packages/epy_reader/board.py", line 53, in render_styles
    self.chgat(row, i.row, i.col, i.n_letters, self.screen.getbkgd() | i.attr)
  File "/home/jason/.local/pipx/venvs/epy-reader/lib/python3.11/site-packages/epy_reader/board.py", line 77, in chgat
    self.screen.chgat(y - row, self.x + x, n, attr)
_curses.error: chgat() returned ERR
epubcheck test.epub 
Validating using EPUB version 3.2 rules.
No errors or warnings detected.
Messages: 0 fatals / 0 errors / 0 warnings / 0 infos

pipx upgrade epy-reader 
epy-reader is already at latest version 2023.6.11 (location: /home/jason/.local/pipx/venvs/epy-reader)

I also tested on a different epub and I did not get the same crash.

I can supply the epub for testing purposes if need be.