From 67b6cb9656e0cfbd556242185fbe80487cd299d2 Mon Sep 17 00:00:00 2001 From: girst Date: Sun, 3 Feb 2019 17:54:57 +0100 Subject: [PATCH] fix segfault when mouse-moving multiple cards to empty tableu the "up to?" dialog calls getch(NULL), which caused a segfault. > Program received signal SIGSEGV, Segmentation fault. > 0x00000000004030fb in getch (buf=0x0) at spider.c:940 > 940 if (buf[3]) { > (gdb) bt > #0 0x00000000004030fb in getch (buf=0x0) at spider.c:940 > #1 0x0000000000402c97 in get_cmd (from=0x7ffeba433bfc, to=0x7ffeba433bf8, > opt=0x7ffeba433bf4) at spider.c:808 > #2 0x0000000000400ebf in sol () at spider.c:108 > #3 0x0000000000400e2f in main (argc=2, argv=0x7ffeba433d28) at spider.c:88 --- sol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sol.c b/sol.c index 1ebd279..ad5aa24 100644 --- a/sol.c +++ b/sol.c @@ -937,7 +937,7 @@ int getch(unsigned char* buf) { /* returns a character, EOF, or constant for an escape/control sequence - NOT compatible with the ncurses implementation of same name */ int action; - if (buf[3]) { + if (buf && buf[3]) { /* mouse was dragged; return 'ungetted' previous destination */ action = MOUSE_DRAG; /* keep original [0], as [3] only contains release event */ -- 2.39.3