1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-11 00:04:24 +00:00

Repro code (example_null; asan error) (!this commit should be ignored when merging!)

This commit is contained in:
achabense 2025-12-05 18:35:58 +08:00
parent d71091a957
commit ea578fb36d
2 changed files with 22 additions and 4 deletions

View file

@ -27,27 +27,29 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

View file

@ -9,6 +9,20 @@
#include "../../backends/imgui_impl_null.h"
#include "../../backends/imgui_impl_null.cpp"
static void repro() {
assert(ImGui::CalcTextSize("a").x == 7);
char str[]{ 'a',' ','b',' ' };
char* str_end = str + sizeof(str);
// char xx = *str_end; // asan error.
ImGui::Begin("Test");
const int wrap_len = 7 * 2;
ImGui::PushTextWrapPos(wrap_len);
ImGui::TextUnformatted(str, str_end); // asan error.
ImGui::PopTextWrapPos();
ImGui::End();
}
int main(int, char**)
{
IMGUI_CHECKVERSION();
@ -32,6 +46,8 @@ int main(int, char**)
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::ShowDemoWindow(nullptr);
repro();
ImGui::Render();
}