improved regexp handling

If regex_compile() fails, free the regexp before doing anything else
in case failure reason is "out of memory".  Feedback to the user is
highly likely to panic or crash after memory runs out; this should
let the regex failure message be issued and the game continue.

User sound regular expressions were never freed.  This frees them
when FREE_ALL_MEMORY is enabled.
This commit is contained in:
PatR
2020-05-23 12:51:01 -07:00
parent 1d7ee022e6
commit 298331fe04
5 changed files with 91 additions and 41 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 save.c $NHDT-Date: 1581886866 2020/02/16 21:01:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.153 $ */
/* NetHack 3.6 save.c $NHDT-Date: 1590263454 2020/05/23 19:50:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.158 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1058,7 +1058,8 @@ NHFILE *nhfp;
if (nhfp->structlevel) {
bufoff(nhfp->fd);
/* bwrite() before bufon() uses plain write() */
bwrite(nhfp->fd, (genericptr_t) &sfsaveinfo, (unsigned) sizeof sfsaveinfo);
bwrite(nhfp->fd, (genericptr_t) &sfsaveinfo,
(unsigned) sizeof sfsaveinfo);
bufon(nhfp->fd);
}
return;
@@ -1149,7 +1150,11 @@ freedynamicdata()
/* miscellaneous */
/* free_pickinv_cache(); -- now done from really_done()... */
free_symsets();
#ifdef USER_SOUNDS
release_sound_mappings();
#endif
#endif /* FREE_ALL_MEMORY */
if (VIA_WINDOWPORT())
status_finish();
#ifdef DUMPLOG