plug potential open file leak in checkfile()
Another item from static analysis. If an internal error ever caused the "bad do_look buffer" warning from checkfile(), open file 'data' would not be closed. (The bug in checkfile()'s caller which prompted that check was fixed long go.) An alternate fix would be to move the input buffer check to before the file is opened, but verifying the file first seems worthwhile.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 pager.c $NHDT-Date: 1543185072 2018/11/25 22:31:12 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.139 $ */
|
||||
/* NetHack 3.6 pager.c $NHDT-Date: 1545129848 2018/12/18 10:44:08 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.142 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2018. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -527,14 +527,14 @@ char *supplemental_name;
|
||||
|
||||
fp = dlb_fopen(DATAFILE, "r");
|
||||
if (!fp) {
|
||||
pline("Cannot open data file!");
|
||||
pline("Cannot open 'data' file!");
|
||||
return;
|
||||
}
|
||||
/* If someone passed us garbage, prevent fault. */
|
||||
if (!inp || strlen(inp) > (BUFSZ - 1)) {
|
||||
impossible("bad do_look buffer passed (%s)!",
|
||||
!inp ? "null" : "too long");
|
||||
return;
|
||||
goto checkfile_done;
|
||||
}
|
||||
|
||||
/* To prevent the need for entries in data.base like *ngel to account
|
||||
|
||||
Reference in New Issue
Block a user