[reader] Fix a bug when going backward and a memory leak

This commit is contained in:
Laury
2021-11-30 22:37:45 +01:00
parent 59fc9a67e4
commit 9cc75f8808
3 changed files with 4 additions and 3 deletions

View File

@@ -169,7 +169,7 @@ Layout TexParser::popCommand() {
}
m_hasError = true;
return LayoutHelper::String(m_text, strlen(m_text));
return EmptyLayout::Builder();
}
// Expressions
@@ -207,4 +207,5 @@ Layout TexParser::popSymbolCommand(int SymbolIndex) {
inline bool TexParser::isCommandEnded(char c) const {
return !(c >= 'a' && c <= 'z') && !(c >= 'A' && c <= 'Z');
}
}

View File

@@ -136,7 +136,7 @@ const char * StartOfPrintableWord(const char * word, const char * start) {
const char * result = word;
while (codePoint != '\n' && codePoint != ' ' && codePoint != '%' && codePoint != '$') {
result = decoder.stringPosition();
if (result >= start) {
if (result <= start) {
break;
}
codePoint = decoder.previousCodePoint();

View File

@@ -74,7 +74,7 @@ void WordWrapTextView::previousPage() {
}
else {
if (*startOfWord == '\\' || *(startOfWord + 1) == '$') {
textSize = m_font->stringSizeUntil(startOfWord + 1, endOfWord);
textSize = m_font->stringSizeUntil(startOfWord + 1, endOfWord);
}
else {
textSize = m_font->stringSizeUntil(startOfWord, endOfWord);