chiark / gitweb /
Patches from Ben Hutchings to fix failures of sscanf error checking.
authorSimon Tatham <anakin@pobox.com>
Fri, 29 Jul 2005 11:24:55 +0000 (11:24 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 29 Jul 2005 11:24:55 +0000 (11:24 +0000)
[originally from svn r6147]

mines.c
pegs.c

diff --git a/mines.c b/mines.c
index f962dd649b55310d46a796b20f23ed9bba494535..d17fdd63769d95aad0659187e25b95c8b2de32f4 100644 (file)
--- 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 5bb5de23e0d5ab9ec163676cf95886dc747be277..4abe116b310d487bad820589cbdbd18fd775ec0e 100644 (file)
--- 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)