mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
fix: prevent potential UB using std::clamp.
### Problem description It is possible for the maximum and minimum value arguments to std::clamp to be swapped which is defined in the standard as undefined behavior ### Implementation description Swap the values if necessary. --------- Co-authored-by: paxcut <53811119+paxcut@users.noreply.github.com>
This commit is contained in:
@@ -335,7 +335,11 @@ namespace hex::plugin::builtin {
|
||||
auto textEditorSize = availableSize;
|
||||
textEditorSize.y *= 3.5F / 5.0F;
|
||||
textEditorSize.y -= ImGui::GetTextLineHeightWithSpacing();
|
||||
textEditorSize.y = std::clamp(textEditorSize.y + height, 200.0F, availableSize.y - 200.0F);
|
||||
if (200.0F > availableSize.y - 200.0F) {
|
||||
textEditorSize.y = std::clamp(textEditorSize.y + height, availableSize.y - 200.0F, 200.0F);
|
||||
} else {
|
||||
textEditorSize.y = std::clamp(textEditorSize.y + height, 200.0F, availableSize.y - 200.0F);
|
||||
}
|
||||
|
||||
if (g.NavWindow != nullptr) {
|
||||
std::string name = g.NavWindow->Name;
|
||||
|
||||
Reference in New Issue
Block a user