From: Simon Tatham Date: Fri, 29 Jul 2005 11:24:55 +0000 (+0000) Subject: Patches from Ben Hutchings to fix failures of sscanf error checking. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=178a86197b8b769bac35a7032313572551614a4d;p=sgt-puzzles.git Patches from Ben Hutchings to fix failures of sscanf error checking. [originally from svn r6147] --- diff --git a/mines.c b/mines.c index f962dd6..d17fdd6 100644 --- a/mines.c +++ b/mines.c @@ -2370,7 +2370,7 @@ static char *encode_ui(game_ui *ui) static void decode_ui(game_ui *ui, char *encoding) { - int p; + int p= 0; sscanf(encoding, "D%d%n", &ui->deaths, &p); if (encoding[p] == 'C') ui->completed = TRUE; diff --git a/pegs.c b/pegs.c index 5bb5de2..4abe116 100644 --- a/pegs.c +++ b/pegs.c @@ -869,7 +869,7 @@ static game_state *execute_move(game_state *state, char *move) int sx, sy, tx, ty; game_state *ret; - if (sscanf(move, "%d,%d-%d,%d", &sx, &sy, &tx, &ty)) { + if (sscanf(move, "%d,%d-%d,%d", &sx, &sy, &tx, &ty) == 4) { int mx, my, dx, dy; if (sx < 0 || sx >= w || sy < 0 || sy >= h)