From 238ec804cf075e36581f42430a13527febbd97b5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 31 Jul 2015 18:38:32 -0400 Subject: SHERLOCK: RT: Fix crash when scrollbar count equals page size --- engines/sherlock/tattoo/widget_base.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp index 539d4a2f02..856d7457b0 100644 --- a/engines/sherlock/tattoo/widget_base.cpp +++ b/engines/sherlock/tattoo/widget_base.cpp @@ -269,7 +269,8 @@ void WidgetBase::drawScrollBar(int index, int pageSize, int count) { // Draw the scroll position bar int barHeight = (r.height() - BUTTON_SIZE * 2) * pageSize / count; barHeight = CLIP(barHeight, BUTTON_SIZE, r.height() - BUTTON_SIZE * 2); - int barY = r.top + BUTTON_SIZE + (r.height() - BUTTON_SIZE * 2 - barHeight) * index / (count - pageSize); + int barY = (count <= pageSize) ? r.top + BUTTON_SIZE : r.top + BUTTON_SIZE + + (r.height() - BUTTON_SIZE * 2 - barHeight) * index / (count - pageSize); _surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE); ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true); -- cgit v1.2.3