mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-18 23:27:44 +03:00
Fix: Footnotes - validate data integrity before render
This commit is contained in:
parent
91a0677503
commit
ad7e9bd267
@ -324,6 +324,47 @@ void EpubReaderActivity::renderScreen() {
|
|||||||
Serial.printf("[%lu] [ERS] Page loaded: %d elements, %d footnotes\n",
|
Serial.printf("[%lu] [ERS] Page loaded: %d elements, %d footnotes\n",
|
||||||
millis(), p->elementCount, p->footnoteCount);
|
millis(), p->elementCount, p->footnoteCount);
|
||||||
|
|
||||||
|
// Check footnote before copy
|
||||||
|
bool hasCorruptedFootnotes = false;
|
||||||
|
for (int i = 0; i < p->footnoteCount && i < 16; i++) {
|
||||||
|
FootnoteEntry* fn = p->getFootnote(i);
|
||||||
|
if (fn) {
|
||||||
|
// Vérifier que number et href sont null-terminés
|
||||||
|
bool numberValid = false;
|
||||||
|
bool hrefValid = false;
|
||||||
|
|
||||||
|
// Chercher le null terminator dans number (3 bytes)
|
||||||
|
for (int j = 0; j < 3; j++) {
|
||||||
|
if (fn->number[j] == '\0') {
|
||||||
|
numberValid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chercher le null terminator dans href (64 bytes)
|
||||||
|
for (int j = 0; j < 64; j++) {
|
||||||
|
if (fn->href[j] == '\0') {
|
||||||
|
hrefValid = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!numberValid || !hrefValid) {
|
||||||
|
Serial.printf("[%lu] [ERS] CORRUPTION DETECTED in footnote %d: number=%d, href=%d\n",
|
||||||
|
millis(), i, numberValid, hrefValid);
|
||||||
|
hasCorruptedFootnotes = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasCorruptedFootnotes) {
|
||||||
|
Serial.printf("[%lu] [ERS] Page has corrupted footnotes - clearing cache\n", millis());
|
||||||
|
section->clearCache();
|
||||||
|
section.reset();
|
||||||
|
return renderScreen();
|
||||||
|
}
|
||||||
|
|
||||||
// Copy footnotes from page to currentPageFootnotes
|
// Copy footnotes from page to currentPageFootnotes
|
||||||
currentPageFootnotes.clear();
|
currentPageFootnotes.clear();
|
||||||
int maxFootnotes = (p->footnoteCount < 16) ? p->footnoteCount : 16;
|
int maxFootnotes = (p->footnoteCount < 16) ? p->footnoteCount : 16;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user