New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LVCssDeclaration::parse(): use auto-resizing buffer #164
Conversation
The fixed sized buffer "buf[512]" can be overflowed (and cause segfaults) on biG CSS declaration (eg: containing many font names in a font-family: property). We use SerialBuf instead and enforce adding 4-bytes ints.
Would it matter at all except in the sense that the cache might be incompatible between architectures? |
@@ -1646,12 +1644,17 @@ bool LVCssDeclaration::parse( const char * &decl ) | |||
} | |||
|
|||
// store parsed result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So even though it says store it does the whole thing every page load, huh? :-)
I think it's fine for cache, as SerialBuf decides about the order the 4bytes of a lUint32 are stored in the SerialBuf, and give the lUint32 back correctly as it knows how to decode them. So, I think this code is using Little-endian. |
Oh, forgot to talk about this. There is this that is called before each rendering (each page turn, menu open...): crengine/crengine/src/lvdocview.cpp Lines 2430 to 2461 in 42dbcf2
It calls among other things: crengine/crengine/src/lvdocview.cpp Lines 491 to 494 in 42dbcf2
I believe we could get rid of this, as it looks to me it's for CoolReader behaviour: with CoolReader, we may change from the UI various settings, including styles, so that's crengine way of knowing some things have changed and that the rendering needs to take them into account. Timing that updateDocStyleSheet says 3ms with a big book on the emulator, so like 30ms on a device. |
I think some ARMs at least support big endian. I don't have anything other than the generic ARMv7 HF in the house though, both on Android and Kobo. |
So, should that go into tonight's crengine/base bump? |
Fine by me. :-) |
The fixed sized buffer
buf[512]
can be overflowed (and cause segfaults) on biG CSS declaration (eg: containing many font names in a font-family: property).We use SerialBuf instead and enforce adding 4-bytes ints.
Fix crash with China.EN.epub as investigated around koreader/koreader#3912 (comment)
I checked with some big test books that caches written with/without this change are readable with no problem (no styleHash mismatch, and quick loading) by crengine without/with this change, so I guess this gives the same result at the end.
I just wonder if
crengine/crengine/src/lvstring.cpp
Lines 4725 to 4734 in 42dbcf2
and
works fine by chance that we got the right endianness or not (do all our platforms share the same endianness as my emulator on x86-64?)