From 091831e44ff336bdcc756dc8203be27796c1838a Mon Sep 17 00:00:00 2001 From: ROOL <code@riscosopen.org> Date: Sat, 21 Dec 2019 09:26:03 +0000 Subject: [PATCH] Apply same vetting to SetCaretPosition window handle as non cut & paste Wimp Detail: Summary of how non-CnP Wimp treats the window handle for Wimp_SetCaretPosition R0 = valid window handle or invalid window handle (mapped to -1) or any negative number or 0 (mapped to -1) With this change, the CnP Wimp does R0 = valid window handle or invalid window handle (throws error) or any negative number or 0 if pre RISC OS 5 (mapped to -1) or 0 for RISC OS 5 (mapped to -1) Noting the use of AcceptLoosePointer macro if built for a 26 bit target. --- s/CnPCaret | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/s/CnPCaret b/s/CnPCaret index 3db69e2..05f999e 100644 --- a/s/CnPCaret +++ b/s/CnPCaret @@ -29,7 +29,6 @@ int_set_caret_position ROUT Push "R0-R6,R11,R14" - [ CnP ; if we're called with R5=-1 then R4,R5 are calculated from R0-R3 ; however, R4 is undefined on entry so could be anything. ; Internally we'd like to be able to use the call to put a ghost caret @@ -44,7 +43,6 @@ int_set_caret_position ROUT 00 CMP R5,#-2 MOVEQ R5,#-1 - ] ; validate existing caret blocks LDR handle,caretdata @@ -98,7 +96,8 @@ int_set_caret_position ROUT BL iconautoscroll_stop Pull "R0,x0,y0,x1,y1" 00 - CMP R0,#-1 + AcceptLoosePointer_NegOrZero R0,nullptr + CMP R0,R0,ASR #31 BEQ %FT07 ; we know this one's not valid MOV handle,R0 BL checkhandle ; valid window handle? @@ -109,7 +108,7 @@ int_set_caret_position ROUT LDR R14,taskidentifier1 ; 'TASK' CMP R2,R14 ; is R2 'TASK' MOVNE R4,#0 ; if we're called with TASK then R4 has correct flags. If not, we need - ; to make sure we have some valid flags + ; to make sure we have some valid flags MOVEQ R2,#0 ; if we were called with R2='TASK' then STREQ R2,[sp,#(2+1+8)*4] ; ensure R2=0 on return - taskhandle stacked below r2 08 -- GitLab