Fixes crash introduced in previous commit 9cf94d5.
diff --git a/imgui_draw.cpp b/imgui_draw.cpp
index 3faa9b0..14d924d 100644
--- a/imgui_draw.cpp
+++ b/imgui_draw.cpp
@@ -2648,9 +2648,8 @@
if (y + line_height < clip_rect.y && !word_wrap_enabled)
while (y + line_height < clip_rect.y && s < text_end)
{
- s = (const char*)memchr(s, '\n', text_end - s) + 1;
- if (s == NULL)
- s = text_end;
+ s = (const char*)memchr(s, '\n', text_end - s);
+ s = s ? s + 1 : text_end;
y += line_height;
}
@@ -2662,7 +2661,8 @@
float y_end = y;
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;
}
text_end = s_end;
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index df83a1d..4e632a9 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -3691,7 +3691,8 @@
break;
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
{