From 3f8f8581c7644c0f0b90a41c815110235581ff0b Mon Sep 17 00:00:00 2001
From: Robert Sprowson <rsprowson@gitlab.riscosopen.org>
Date: Sun, 11 Dec 2022 18:55:06 +0000
Subject: [PATCH] [509] Fix abort autoscrolling off a window with no icons

When looking up the user icon button type passed in R3/R4, use the window handle
in R3 rather than 'handle' which is the window in which autoscrolling started.
This caused an abort if that window contained no icons (because w_icons = -1, and
R4 != -1 leading to R5 = 15 and invariably an address in zero page somewhere).
---
 s/Wimp03 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/s/Wimp03 b/s/Wimp03
index 3a0fbe7..8e0a052 100644
--- a/s/Wimp03
+++ b/s/Wimp03
@@ -1998,8 +1998,9 @@ cantchange
 ; obtain 'button type' of user icon
 ;
 01      CMP     R4,#nullptr
-        LDREQ   R5,[handle,#w_workflags]; look up work area button type
-        LDRNE   R5,[handle,#w_icons]
+        Abs     R14,R3
+        LDREQ   R5,[R14,#w_workflags]   ; look up work area button type
+        LDRNE   R5,[R14,#w_icons]
         ADDNE   R5,R5,#i_flags
         LDRNE   R5,[R5,R4,ASL #i_shift] ; R5 = flag word
 ;
-- 
GitLab