From 00a32916a74a7d590410655f2c965053a5f71de4 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 29 Jul 2005 11:24:55 +0000 Subject: [PATCH] Patches from Ben Hutchings to fix failures of sscanf error checking. git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6147 cda61777-01e9-0310-a592-d414129be87e --- mines.c | 2 +- pegs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) -- 2.11.0