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:
Kris Austin authored and GitHub committed 2026-10-19 16:25:07 -05:00
1 parent a2b1a2f3e7
commit 9fd141312e
2 files changed
+4 -2

No files matched your search

+3 -1
View File
@@ -36839,7 +36839,9 @@ msgstr ""
msgid ""
"Reverse on even\n"
"Did you know that <b>Reverse on even</b> feature can significantly improve the surface quality of your overhangs? However, it can cause wall inconsistencies so use carefully!"
msgstr "Реверс на чётных слояхСовет: настройка <b>Реверс на чётных слоях</b> может существенно улучшить качество нависающих поверхностей. Как и нарушить их однородность, так что используйте с осторожностью."
msgstr ""
"Реверс на чётных слоях\n"
"Совет: настройка <b>Реверс на чётных слоях</b> может существенно улучшить качество нависающих поверхностей. Как и нарушить их однородность, так что используйте с осторожностью."
#: resources/data/hints.ini: [hint:Cut Tool]
msgid ""
+1 -1
View File
@@ -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];