win32ss/user/ntuser/scrollbar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32ss/user/ntuser/scrollbar.c b/win32ss/user/ntuser/scrollbar.c index 325be6fe49..b852b662c2 100644 --- a/win32ss/user/ntuser/scrollbar.c +++ b/win32ss/user/ntuser/scrollbar.c @@ -595,7 +595,8 @@ co_IntSetScrollInfo(PWND Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) if (lpsi->fMask & (SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL)) { new_flags = Window->pSBInfo->WSBflags; - if (Info->nMin >= (int)(Info->nMax - max(Info->nPage - 1, 0))) + /* Cast Info->nPage to int to prevent wraparound/underflow. Fixes CORE-16491 */ + if (Info->nMin >= (int)(Info->nMax - max((int)Info->nPage - 1, 0))) { /* Hide or disable scroll-bar */ if (lpsi->fMask & SIF_DISABLENOSCROLL)