]> granicus.if.org Git - nethack/commit
prevent pline() segfault
authorPatR <rankin@nethack.org>
Tue, 13 Mar 2018 18:27:04 +0000 (11:27 -0700)
committerPatR <rankin@nethack.org>
Tue, 13 Mar 2018 18:27:04 +0000 (11:27 -0700)
commitc28b44c27c7adb2f48bab495f12e81229f57a062
treeddc18446f04e9e74b3cfdad8041eaec7d43a6b5b
parent0b6e26d9e0a85da01addd82ac93e2b760326f356
prevent pline() segfault

The use of debugpline() in tty_curs() got me wondering what would
happen if debugpline() was called while pline() is in progress.  I
don't know how to trigger the bad coordinate situation, so I put an
unconditional debugpline() in the NHW_MESSAGE case of tty_putstr()
and used DEBUGFILES=wintty.c to enable it.  Instant segfault, and
the backtrace was short and not useful so the stack might have been
clobbered.  I didn't spend any time trying to figure where or why
the segfault occurred.

Change pline() so that if it is called while the previous pline()
hasn't finished yet (ie, recursively), use raw_print() and return
early.  The raw_print message isn't very useful--it pops up wherever
the cursor happens to be, just like the cursor position bug that has
been an issue recently--but does get delivered without any segualt
and isn't completely useless if DUMPLOG is enabled and you save or
quit before the message buffer gets recycled.  Message readability
situation could be improved but avoiding the segfault was my goal.

Putting any debugpline() into *_raw_print() would be inadvisable....
doc/fixes36.1
src/pline.c