chiark / gitweb /
Fix a memory management bug in Filling: in some situations its
authorSimon Tatham <anakin@pobox.com>
Sat, 13 Apr 2013 10:37:27 +0000 (10:37 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 13 Apr 2013 10:37:27 +0000 (10:37 +0000)
solve_game() was returning its aux parameter un-dupstr()ed, which is
wrong. Also clarified the developer docs on that function to make it
clearer that the returned string should be dynamic.

[originally from svn r9831]

devel.but
filling.c

index e95e1d2ded0c6b71523380e9dea92b7c290f9f52..75ddeb785524124abba4768a2e9fad7483203bc3 100644 (file)
--- a/devel.but
+++ b/devel.but
@@ -1020,9 +1020,11 @@ it may return \cw{NULL}. If it does this, it must also set
 \q{Solution not known for this puzzle}); that error message is not
 expected to be dynamically allocated.
 
-If this function \e{does} produce a solution, it returns a move
-string suitable for feeding to \cw{execute_move()}
-(\k{backend-execute-move}).
+If this function \e{does} produce a solution, it returns a move string
+suitable for feeding to \cw{execute_move()}
+(\k{backend-execute-move}). Like a (non-empty) string returned from
+\cw{interpret_move()}, the returned string should be dynamically
+allocated.
 
 \H{backend-drawing} Drawing the game graphics
 
index 4cd4318b41999a862bbfa5cd19049b707ce0354a..cad0733e77135f4bba63dfb508f5177f6e6adbc7 100644 (file)
--- a/filling.c
+++ b/filling.c
@@ -975,7 +975,7 @@ static char *solve_game(game_state *state, game_state *currstate,
         if (!solver(state->board, w, h, &aux))
             *error = "Sorry, I couldn't find a solution";
     }
-    return aux;
+    return dupstr(aux);
 }
 
 /*****************************************************************************