lvrend: fix possible buffer overflow#613
lvrend: fix possible buffer overflow#613benoit-pierre wants to merge 1 commit intokoreader:masterfrom
Conversation
3791b5b to
7a51eb6
Compare
7a51eb6 to
a5e7eae
Compare
|
Not sure I like that, replacing the cheap There is the same kind of work in lvtextfm.cpp, with static buffers too, but there, the logic is we stop feeding and go In my getRenderedWidths(), it looks like I don't do that, although the I'd rather fix it in the spirit of the current code, than switching to new/delete. (I remember I've seen in some changes of yours that you haven't pushed here that you were replacing all the static m_* buffers in lvtextfm with new/delete. I would have stated the avove if you had proposed it here :)) |
And I hate it too: it's wasting 680KB (on x86_64)! I've benchmarked the change on PC, and I'm not seeing any meaningful impact. |
It's not wasted: it's re-used each time you turn a page to render new paragraphs. It's there, already allocated, waiting for your requests, without the neeed to malloc and free. (The same goes for the lvtextfm m_* buffers - it's not just used when we render() the full book, it's used each time we need to draw a paragraph - there are a small amount of rendered paragraphs that is cached, so when you go back a page you may meet them, but when you go forwards, new paragraphs needs to be renredered for drawing). |
When trying to load of 34 MB EPUB (Kotlin Docs), the actual maximum length goes up to 6037.
This change is