# HG changeset patch # User Mike Becker # Date 1396984408 -7200 # Node ID ed440bcd9740305841cf7004087c9a3eb82acc11 # Parent a285ee393860a0023f8a9c1a92645557912cee9c fixed some type bugs, uninitialized memory and async input function diff -r a285ee393860 -r ed440bcd9740 src/game.c --- a/src/game.c Mon Apr 07 17:39:46 2014 +0200 +++ b/src/game.c Tue Apr 08 21:13:28 2014 +0200 @@ -154,6 +154,7 @@ const size_t buflen = 8; char movestr[buflen]; + movestr[0] = '\0'; int inputy = getmaxy(stdscr) - 6; while (1) { @@ -205,6 +206,7 @@ } clrtoeol(); } + movestr[0] = '\0'; /* reset string for next input */ } } } diff -r a285ee393860 -r ed440bcd9740 src/input.c --- a/src/input.c Mon Apr 07 17:39:46 2014 +0200 +++ b/src/input.c Tue Apr 08 21:13:28 2014 +0200 @@ -28,6 +28,7 @@ */ #include "input.h" +#include void init_colorpairs() { init_pair(COL_YB, COLOR_YELLOW, COLOR_BLUE); @@ -70,6 +71,7 @@ static size_t pos = 0; if (*str == '\0') { + memset(str, 0, len); pos = 0; } @@ -88,7 +90,7 @@ str[--pos] = '\0'; break; default: - if (c < 255 && pos < len-1) { + if (isprint(c) && pos < len-1) { str[pos++] = (char) c; } } diff -r a285ee393860 -r ed440bcd9740 src/main.c --- a/src/main.c Mon Apr 07 17:39:46 2014 +0200 +++ b/src/main.c Tue Apr 08 21:13:28 2014 +0200 @@ -40,7 +40,7 @@ uint8_t timeunit = 60; size_t len; - for (char opt ; (opt = getopt(argc, argv, "a:bhp:rst:")) != -1 ;) { + for (int opt ; (opt = getopt(argc, argv, "a:bhp:rst:")) != -1 ;) { switch (opt) { case 'b': settings->gameinfo.servercolor = BLACK;