summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authorTom Englund <tomenglund26@gmail.com>2024-06-30 13:15:59 +0200
committerGitHub <noreply@github.com>2024-06-30 13:15:59 +0200
commit8ff9410d2cd39fc1c677799a29f7a063743c0dc9 (patch)
tree5da401760dc4d6426f098a072020b2219cf994ac /src/managers/input/InputManager.cpp
parent718afe271ecebfe6711453b9cfee90fa49a7e761 (diff)
inputmgr: ensure we dont divide by zero (#6713)
some weird combination of scrolling/nesting hyprland and closing a window i managed to divide by zero here, reported by ubsan. add a check to ensure we dont hit UB.
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index b3621520..9180e9cd 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -798,7 +798,7 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
}
}
}
- double deltaDiscrete = factor * e.deltaDiscrete / std::abs(e.deltaDiscrete);
+ double deltaDiscrete = (e.deltaDiscrete != 0) ? (factor * e.deltaDiscrete / std::abs(e.deltaDiscrete)) : 0;
g_pSeatManager->sendPointerAxis(e.timeMs, e.axis, factor * e.delta, deltaDiscrete > 0 ? std::ceil(deltaDiscrete) : std::floor(deltaDiscrete),
std::round(factor * e.deltaDiscrete), e.source, WL_POINTER_AXIS_RELATIVE_DIRECTION_IDENTICAL);
}