fix github issue #832 - "nethack --nethackrc=file"
Issue reported by schauveau: when the command line specifies the '--nethackrc=file' option (Unix, including linux and OSX, only) the value of 'file' was set in pointer g.cmdline_rcfile and the options parsing made a copy of that pointer rather than of what it pointed to, then freed g.cmdline_rcfile before using the copy. So it ended up using a pointer to freed memory. Stick with copying the pointer but defer freeing the original until after its copy is no longer needed. Fixes #832
This commit is contained in:
@@ -1331,6 +1331,9 @@ when one monster swallowed/engulfed another and killed it, impossible
|
|||||||
"placing <mon> over itself ..." could be given by place_monster()
|
"placing <mon> over itself ..." could be given by place_monster()
|
||||||
if the game crashed or the process was killed, recovering a save file ended
|
if the game crashed or the process was killed, recovering a save file ended
|
||||||
up with incorrect stairway connections between levels
|
up with incorrect stairway connections between levels
|
||||||
|
when using --nethackrc=file on the command line (currently only implemented
|
||||||
|
for ports that use unixmain.c), options parsing freed the string
|
||||||
|
containing 'file' before using it as the RC file name
|
||||||
|
|
||||||
curses: 'msg_window' option wasn't functional for curses unless the binary
|
curses: 'msg_window' option wasn't functional for curses unless the binary
|
||||||
also included tty support
|
also included tty support
|
||||||
|
|||||||
+3
-1
@@ -6233,7 +6233,6 @@ initoptions_finish(void)
|
|||||||
if (g.cmdline_rcfile) {
|
if (g.cmdline_rcfile) {
|
||||||
namesrc = "command line";
|
namesrc = "command line";
|
||||||
nameval = g.cmdline_rcfile;
|
nameval = g.cmdline_rcfile;
|
||||||
free((genericptr_t) g.cmdline_rcfile), g.cmdline_rcfile = 0;
|
|
||||||
xtraopts = opts;
|
xtraopts = opts;
|
||||||
if (opts && (*opts == '/' || *opts == '\\' || *opts == '@'))
|
if (opts && (*opts == '/' || *opts == '\\' || *opts == '@'))
|
||||||
xtraopts = 0; /* NETHACKOPTIONS is a file name; ignore it */
|
xtraopts = 0; /* NETHACKOPTIONS is a file name; ignore it */
|
||||||
@@ -6274,6 +6273,9 @@ initoptions_finish(void)
|
|||||||
(void) parseoptions(xtraopts, TRUE, FALSE);
|
(void) parseoptions(xtraopts, TRUE, FALSE);
|
||||||
config_error_done();
|
config_error_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g.cmdline_rcfile)
|
||||||
|
free((genericptr_t) g.cmdline_rcfile), g.cmdline_rcfile = 0;
|
||||||
/*[end of nethackrc handling]*/
|
/*[end of nethackrc handling]*/
|
||||||
|
|
||||||
(void) fruitadd(g.pl_fruit, (struct fruit *) 0);
|
(void) fruitadd(g.pl_fruit, (struct fruit *) 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user