mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-20 14:08:20 +00:00
Fix random crash while slicing with the Russian UI (daily tips) (#16664)
Fix crash when a daily tip has no body text has_cjk() looped while i < text.size() - 2. For a string shorter than two bytes the size_t subtraction wraps, so on an empty string the loop read past the buffer and up the stack until it hit an unmapped page. The Russian translation of the "Reverse on even" tip had lost the \n after its title, so render_text() passed an empty body to has_cjk() every time that tip was shown during slicing. Restore the line break and bound the loop so a translation like this can't crash the app.
This commit is contained in:
1 parent
a2b1a2f3e7
commit
f64beb4379
2 files changed
+4
-2
No files matched your search
@@ -161,7 +161,7 @@ void DailyTipsDataRenderer::render_img(const ImVec2& start_pos, const ImVec2& si
|
||||
|
||||
bool has_cjk(const std::string &text)
|
||||
{
|
||||
for (size_t i = 0; i < text.size() - 2; ++i) {
|
||||
for (size_t i = 0; i + 2 < text.size(); ++i) {
|
||||
unsigned char c1 = text[i];
|
||||
unsigned char c2 = text[i + 1];
|
||||
unsigned char c3 = text[i + 2];
|
||||
|
||||
Reference in new issue
Block a user