ref: 8ddfc3904bb200fa74a383573e1b353ff3143114
parent: f3ba6f8bcefde0ff75971e662841ecef6be56b5a
author: Jacob Nevins <jacobn@chiark.greenend.org.uk>
date: Sat May 21 18:07:48 EDT 2005
Ensure that an old random seed isn't left around for the user to see when a descriptive ID has been specified. Fix tiny memory leak. [originally from svn r5825]
--- a/midend.c
+++ b/midend.c
@@ -748,6 +748,7 @@
if (seed || desc) {
char *tmpstr = me->ourgame->encode_params(tmpparams, FALSE);
me->ourgame->decode_params(me->params, tmpstr);
+ sfree(tmpstr);
} else {
me->ourgame->free_params(me->params);
me->params = me->ourgame->dup_params(tmpparams);
@@ -754,12 +755,16 @@
}
}
+ sfree(me->desc);
+ me->desc = NULL;
+ sfree(me->seedstr);
+ me->seedstr = NULL;
+
if (desc) {
error = me->ourgame->validate_desc(me->params, desc);
if (error)
return error;
- sfree(me->desc);
me->desc = dupstr(desc);
me->genmode = GOT_DESC;
if (me->aux_info)
@@ -768,7 +773,6 @@
}
if (seed) {
- sfree(me->seedstr);
me->seedstr = dupstr(seed);
me->genmode = GOT_SEED;
}