]> git.neil.brown.name Git - edlib.git/commitdiff
display-ncurses: ignore focus changes better.
authorNeilBrown <neil@brown.name>
Sat, 19 Aug 2023 22:34:13 +0000 (08:34 +1000)
committerNeilBrown <neil@brown.name>
Sun, 20 Aug 2023 22:47:04 +0000 (08:47 +1000)
If we got a focus change message, 'buf' would be uninitialised and used.
So initialise it - and don't use it.

Signed-off-by: NeilBrown <neil@brown.name>
display-ncurses.c

index 0b1eda0784b1d5f785aa346d0592ef44586d6d2c..1e854f42bcf0190595a49bad9f4f5cd7b5867d19 100644 (file)
@@ -1559,7 +1559,8 @@ static void send_key(int keytype, wint_t c, int alt, struct pane *p safe)
                        LOG("Unknown ncurses key 0o%o", c);
                        sprintf(buf, "%sNcurs-%o", a, c);
                } else if (strstarts(n, ":Focus-"))
-                       /* Ignore focus changes for now */;
+                       /* Ignore focus changes for now */
+                       buf[0] = 0;
                else
                        strcat(strcpy(buf, a), n);
        } else {
@@ -1574,8 +1575,10 @@ static void send_key(int keytype, wint_t c, int alt, struct pane *p safe)
        }
 
        dd->last_event = time(NULL);
-       record_key(p, buf);
-       call("Keystroke", p, 0, NULL, buf);
+       if (buf[0]) {
+               record_key(p, buf);
+               call("Keystroke", p, 0, NULL, buf);
+       }
 }
 
 static void do_send_mouse(struct pane *p safe, int x, int y, char *cmd safe,