shithub: puzzles

Download patch

ref: 08c8cf370ef7575a78988eb7d8f98c2a0bb92c63
parent: efda6cff49e7579b5c10b16694ac57340ce2fc2b
author: Simon Tatham <anakin@pobox.com>
date: Sun Sep 11 07:57:24 EDT 2005

Marginally greater robustness in the face of solve_game() failing to
return an error message.

[originally from svn r6288]

--- a/midend.c
+++ b/midend.c
@@ -1167,12 +1167,15 @@
     if (me->statepos < 1)
 	return "No game set up to solve";   /* _shouldn't_ happen! */
 
-    msg = "Solve operation failed";    /* game _should_ overwrite on error */
+    msg = NULL;
     movestr = me->ourgame->solve(me->states[0].state,
 				 me->states[me->statepos-1].state,
 				 me->aux_info, &msg);
-    if (!movestr)
+    if (!movestr) {
+	if (!msg)
+	    msg = "Solve operation failed";   /* _shouldn't_ happen, but can */
 	return msg;
+    }
     s = me->ourgame->execute_move(me->states[me->statepos-1].state, movestr);
     assert(s);