[comp.sources.d] another bug in rogue

simon@its63b.ed.ac.uk (ECSC68 S Brown CS) (03/19/87)

Well, here's another null-pointer bug in the rogue that was posted recently
in comp.sources.unix. (Actually, it was a *REAL* bug - if the first monster
on the level was a mimic, it remained mimicking (sp?) even though it should
be identified; this patch fixes that too).

The symptom of the bug was that if you read a scroll of aggregate monsters
on a machine which memory-faults on a null-pointer dereference, the game
core-dumps.

Here's a context diff:

(Yes, I *know* it should be in comp.source.bugs, but I can't post there!)


*** monster.c.orig	Thu Mar 19 16:41:15 1987
--- monster.c	Thu Mar 19 16:41:08 1987
***************
*** 790,796
  	while (monster) {
  		wake_up(monster);
  		monster->m_flags &= (~IMITATES);
- 		monster = monster->next_monster;	
  		if (rogue_can_see(monster->row, monster->col)) {
  			mvaddch(monster->row, monster->col, monster->m_char);
  		}

--- 790,795 -----
  	while (monster) {
  		wake_up(monster);
  		monster->m_flags &= (~IMITATES);
  		if (rogue_can_see(monster->row, monster->col)) {
  			mvaddch(monster->row, monster->col, monster->m_char);
  		}
***************
*** 794,799
  		if (rogue_can_see(monster->row, monster->col)) {
  			mvaddch(monster->row, monster->col, monster->m_char);
  		}
  	}
  }
  

--- 793,799 -----
  		if (rogue_can_see(monster->row, monster->col)) {
  			mvaddch(monster->row, monster->col, monster->m_char);
  		}
+ 		monster = monster->next_monster;	
  	}
  }
  
-- 
----------------------------------
| Simon Brown 		         | UUCP:  seismo!mcvax!ukc!{its63b,cstvax}!simon
| Department of Computer Science | JANET: simon@uk.ac.ed.{its63b,cstvax}
| University of Edinburgh,       | ARPA:  simon%{its63b,cstvax}.ed.ac.uk\
| Scotland, UK.			 |				@cs.ucl.ac.uk
----------------------------------	 "Life's like that, you know"