Fixes crash introduced in previous commit 9cf94d5.

This commit is contained in:
omar 2018-10-12 13:29:13 +02:00
parent c398153b40
commit 2eaf5b03df
2 changed files with 6 additions and 5 deletions

View File

@ -2669,9 +2669,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
if (y + line_height < clip_rect.y && !word_wrap_enabled) if (y + line_height < clip_rect.y && !word_wrap_enabled)
while (y + line_height < clip_rect.y && s < text_end) while (y + line_height < clip_rect.y && s < text_end)
{ {
s = (const char*)memchr(s, '\n', text_end - s) + 1; s = (const char*)memchr(s, '\n', text_end - s);
if (s == NULL) s = s ? s + 1 : text_end;
s = text_end;
y += line_height; y += line_height;
} }
@ -2683,7 +2682,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
float y_end = y; float y_end = y;
while (y_end < clip_rect.w && s_end < text_end) while (y_end < clip_rect.w && s_end < text_end)
{ {
s_end = (const char*)memchr(s_end, '\n', text_end - s_end) + 1; s_end = (const char*)memchr(s_end, '\n', text_end - s_end);
s = s ? s + 1 : text_end;
y_end += line_height; y_end += line_height;
} }
text_end = s_end; text_end = s_end;

View File

@ -3714,7 +3714,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
break; break;
if (rect_pos.y < clip_rect.y) if (rect_pos.y < clip_rect.y)
{ {
p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p) + 1; p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p);
p = p ? p + 1 : text_selected_end;
} }
else else
{ {