Commit 091831e4 authored by ROOL's avatar ROOL :robot:
Browse files

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.
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment