OSDN Git Service

Mac: add paranoia about big cursor extending beyond a terminal's bounds
authorEric Branlund <ebranlund@fastmail.com>
Tue, 25 Apr 2023 04:39:53 +0000 (22:39 -0600)
committerEric Branlund <ebranlund@fastmail.com>
Tue, 25 Apr 2023 04:39:53 +0000 (22:39 -0600)
src/main-cocoa.mm

index a567e58..ed43699 100644 (file)
@@ -4598,9 +4598,11 @@ static errr Term_bigcurs_cocoa(TERM_LEN x, TERM_LEN y)
 {
     AngbandContext *angbandContext =
        (__bridge AngbandContext*) (game_term->data);
+    /* Out of paranoia, coerce to remain in bounds. */
+    int w = (x + 2 <= angbandContext.cols) ? 2 : angbandContext.cols - x;
 
-    [angbandContext.contents setCursorAtColumn:x row:y width:2 height:1];
-    [angbandContext.changes markChangedBlockAtColumn:x row:y width:2 height:1];
+    [angbandContext.contents setCursorAtColumn:x row:y width:w height:1];
+    [angbandContext.changes markChangedBlockAtColumn:x row:y width:w height:1];
 
     /* Success */
     return 0;