[comp.sources.bugs] A bug in UNIX Moria fixed

john@frog.UUCP (John Woods, Software) (01/22/88)

There is a bug in UNIX Moria to which I've not seen a fix, so I'll post mine.
If you read a Scroll of Enchant Armor wearing 5 pieces of armor, it will loop
forever trying to enchant them (at least, that's what it does here -- due to
the nature of the bug, there's no telling what it will do to YOU).

The bug is that the enchant armor scroll refers to tmp[1], tmp[2], tmp[3],
tmp[4], and tmp[5] -- but since tmp is defined as 'int tmp[5];' on line 20
of scrolls.c, there isn't a tmp[5] (that's zero-origin arrays for you).
The fix is to change line 20 to declare 'int tmp[6];'  (or you could fiddle
with the code to use tmp[0], but it seems better to burn an int-worth of
stack than two or three ints-worth (perhaps) of code space).

--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw@eddie.mit.edu

"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation."
		-- Johnny Hart