Skip to content

Commit

Permalink
Text: fix read/write outside array bounds
Browse files Browse the repository at this point in the history
Similar and followup to bc4500a, where we forgot to do it
also for images and inlineBoxes...
  • Loading branch information
virxkane authored and poire-z committed Jul 15, 2020
1 parent 8e9fe3e commit 0a46f76
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions crengine/src/lvtextfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,10 +1081,12 @@ class LVFormatter {
// (it will allow wrap before and after an object, unless it's near
// some punctuation/quote/paren, whose rules will be ensured it seems).
int brk = lb_process_next_char(&lbCtx, (utf32_t)0xFFFC); // OBJECT REPLACEMENT CHARACTER
if (brk == LINEBREAK_ALLOWBREAK)
m_flags[pos-1] |= LCHAR_ALLOW_WRAP_AFTER;
else
m_flags[pos-1] &= ~LCHAR_ALLOW_WRAP_AFTER;
if (pos > 0) {
if (brk == LINEBREAK_ALLOWBREAK)
m_flags[pos-1] |= LCHAR_ALLOW_WRAP_AFTER;
else
m_flags[pos-1] &= ~LCHAR_ALLOW_WRAP_AFTER;
}
#else
m_flags[pos] |= LCHAR_ALLOW_WRAP_AFTER;
#endif
Expand All @@ -1102,10 +1104,12 @@ class LVFormatter {
#if (USE_LIBUNIBREAK==1)
// Let libunibreak know there was an object
int brk = lb_process_next_char(&lbCtx, (utf32_t)0xFFFC); // OBJECT REPLACEMENT CHARACTER
if (brk == LINEBREAK_ALLOWBREAK)
m_flags[pos-1] |= LCHAR_ALLOW_WRAP_AFTER;
else
m_flags[pos-1] &= ~LCHAR_ALLOW_WRAP_AFTER;
if (pos > 0) {
if (brk == LINEBREAK_ALLOWBREAK)
m_flags[pos-1] |= LCHAR_ALLOW_WRAP_AFTER;
else
m_flags[pos-1] &= ~LCHAR_ALLOW_WRAP_AFTER;
}
#else
m_flags[pos] |= LCHAR_ALLOW_WRAP_AFTER;
#endif
Expand Down

0 comments on commit 0a46f76

Please sign in to comment.