fix UB in mem edit

This commit is contained in:
silverweed 2024-07-25 10:53:34 +02:00
parent ca9b536a54
commit bf3fe17393

View file

@ -436,7 +436,11 @@ struct MemoryEditor
ImGui::SameLine(s.PosAsciiStart);
ImVec2 pos = ImGui::GetCursorScreenPos();
addr = (size_t)line_i * Cols;
size_t mouseAddr = addr + (size_t)((ImGui::GetIO().MousePos.x - pos.x) / s.GlyphWidth);
float mposx = ImGui::GetIO().MousePos.x;
float posdiff = mposx - pos.x;
if (posdiff < 0)
posdiff = 0;
size_t mouseAddr = addr + (size_t)(posdiff / s.GlyphWidth);
ImGui::PushID(line_i);
if (ImGui::InvisibleButton("ascii", ImVec2(s.PosAsciiEnd - s.PosAsciiStart, s.LineHeight)))
{