shithub: puzzles

Download patch

ref: 178a86197b8b769bac35a7032313572551614a4d
parent: 19c9453b5c4a1ee0afaf9b85d2c107b70c627cd0
author: Simon Tatham <anakin@pobox.com>
date: Fri Jul 29 07:24:55 EDT 2005

Patches from Ben Hutchings to fix failures of sscanf error checking.

[originally from svn r6147]

--- a/mines.c
+++ b/mines.c
@@ -2370,7 +2370,7 @@
 
 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;
--- a/pegs.c
+++ b/pegs.c
@@ -869,7 +869,7 @@
     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)