You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Unrelated to backends) imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler, OS:
(Unrelated to compiler and OS) MSVC 2022, Windows 11
Full config/build information:
Unrelated to configuration
Details:
I'm looking at ImDrawList::AddText(), but there are other functions that accept a text range. The code that handles text_begin/text_end looks like this:
if (text_end == NULL)
text_end = text_begin + strlen(text_begin);
if (text_begin == text_end)
return;
If text_begin equals text_end equals NULL, the code will call strlen() on NULL. This can reasonably happen when text_begin and text_end are directly taken from an std::string_view as data() and data() + size(), since a default-constructed std::string_view has NULL as data() as size() of 0. I believe, adding 0 to a null pointer is valid.
Instead, AddText (and other functions) could do something like
if (text_end == NULL && text_begin != NULL)
text_end = text_begin + strlen(text_begin);
if (text_begin == text_end)
return;
Obviously, the caller can work around this by placing the condition text_begin != NULL before the call.
Version/Branch of Dear ImGui:
Version 1.90.4, Branch: master (I guess?)
Back-ends:
(Unrelated to backends) imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler, OS:
(Unrelated to compiler and OS) MSVC 2022, Windows 11
Full config/build information:
Unrelated to configuration
Details:
I'm looking at
ImDrawList::AddText()
, but there are other functions that accept a text range. The code that handlestext_begin
/text_end
looks like this:If
text_begin
equalstext_end
equalsNULL
, the code will callstrlen()
onNULL
. This can reasonably happen whentext_begin
andtext_end
are directly taken from anstd::string_view
asdata()
anddata() + size()
, since a default-constructedstd::string_view
hasNULL
asdata()
assize()
of0
. I believe, adding0
to a null pointer is valid.Instead,
AddText
(and other functions) could do something likeObviously, the caller can work around this by placing the condition
text_begin != NULL
before the call.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: