[comp.os.minix] Fix for adventure

timcc@csv.viccol.edu.au (Tim Cook) (10/26/90)

The version of adventure posted by Robert R. Hall has a bug that I have
found.  It may not affect Minix users (I have not tested adventure under
Minix, I'm so slow, I haven't even upgraded to 1.5 :-), but it makes advent
die with a segmentation fault under DYNIX (4.2 bsd derivative).

I tracked it down to a routine in database.c that writes -1 into a field of
an entry in the travel array, to denote the end of that array (this happens
on line 28 of database.c).  Unfortunately, it actually writes just past the
array, setting the value of a file pointer to -1.  This causes a
segmentation fault when you try to move at the start of the game.

Enough banter, the fix is simple:

*** advdef.h.dist	Thu Oct 25 14:53:09 1990
--- advdef.h	Thu Oct 25 18:12:18 1990
***************
*** 6,12 ****
  /*
    Database variables
  */
! struct trav travel[MAXTRAV];
  FILE *fd1, *fd2, *fd3, *fd4;
  int actmsg[32];			/* action messages	 */
  
--- 6,12 ----
  /*
    Database variables
  */
! struct trav travel[MAXTRAV+1];
  FILE *fd1, *fd2, *fd3, *fd4;
  int actmsg[32];			/* action messages	 */
  
--
Tim Cook     Systems Administrator, Victoria College Computer Services

parrot - n.  An animal that has the ability to imitate man, but not the
             intelligence to refrain from doing so.

HBO043%DJUKFA11.BITNET@cunyvm.cuny.edu (Christoph van Wuellen) (10/30/90)

I think I reported and fixed that bug two days after adventure was
posted. The real fix is not to increase the dimension size, but
to change a ++i or something like that.

The author of adventure told me that this is the right thing.

The effect (a filepointer becoming -1) was the same on the Sun here, BTW.

Christoph van Wuellen.