fix(audit): pass 1 — clamp resize-overlay-duration before narrowing to int

resize-overlay-duration is a Duration whose millisecond value
(Duration.cval → asMilliseconds, a c_uint) can exceed INT_MAX. The
unguarded static_cast<int> would wrap to a negative interval, which
QTimer::start() rejects — leaving the resize overlay stuck on screen.
Clamp to INT_MAX before the cast.

Co-Authored-By: claude-flow <ruv@ruv.net>
pull/12846/head
Nathan 2026-05-21 14:37:53 -05:00
parent ac5d068040
commit e6e96c78c4
1 changed files with 8 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <limits>
#include <QByteArray>
#include <QClipboard>
@ -527,8 +528,14 @@ void GhosttySurface::showResizeOverlay() {
// vanished the instant it appeared.
unsigned long long durCfgMs = 0;
const bool durOk = configGet(cfg, &durCfgMs, "resize-overlay-duration");
// Clamp before narrowing: a Duration's millisecond value can exceed
// INT_MAX, and a wrapped negative int would make QTimer::start()
// reject the interval, leaving the overlay stuck on screen.
const int durMs =
(durOk && durCfgMs > 0) ? static_cast<int>(durCfgMs) : 750;
(durOk && durCfgMs > 0)
? static_cast<int>(std::min<unsigned long long>(
durCfgMs, std::numeric_limits<int>::max()))
: 750;
if (!m_resizeHideTimer) {
m_resizeHideTimer = new QTimer(this);
m_resizeHideTimer->setSingleShot(true);