Skip to content

Commit

Permalink
lvrend: fix possible buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-pierre committed Jan 31, 2025
1 parent 3e1ee18 commit a5e7eae
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crengine/src/lvrend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12273,9 +12273,8 @@ void getRenderedWidths(ldomNode * node, int &maxWidth, int &minWidth, int direct
printf("GRW text: |%s|\n", UnicodeToLocal(text).c_str());
printf("GRW text: (dumb text size=%d)\n", font->getTextWidth(txt, len));
#endif
#define MAX_TEXT_CHUNK_SIZE 4096
static lUInt16 widths[MAX_TEXT_CHUNK_SIZE+1];
static lUInt8 flags[MAX_TEXT_CHUNK_SIZE+1];
lUInt16 *widths = new lUInt16[len];
lUInt8 *flags = new lUInt8[len];

// todo: use fribidi and split measurement at fribidi level change,
// and beware left/right side bearing adjustments...
Expand Down Expand Up @@ -12527,6 +12526,8 @@ void getRenderedWidths(ldomNode * node, int &maxWidth, int &minWidth, int direct
len -= chars_measured;
start += chars_measured;
}
delete [] widths;
delete [] flags;
}
#ifdef DEBUG_GETRENDEREDWIDTHS
printf("GRW current: max=%d word=%d (max=%d, min=%d)\n", curMaxWidth, curWordWidth, maxWidth, minWidth);
Expand Down

0 comments on commit a5e7eae

Please sign in to comment.