Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!psuvax1!burdvax!sdcrdcf!psivax!quad1!oleg From: oleg@quad1.quad.com (Oleg Kiselev) Newsgroups: comp.sources.bugs Subject: robots2 Message-ID: <1019@quad1.quad.com> Date: Thu, 13-Aug-87 18:41:21 EDT Article-I.D.: quad1.1019 Posted: Thu Aug 13 18:41:21 1987 Date-Received: Sun, 16-Aug-87 06:49:26 EDT Reply-To: oleg@quad1.UUCP (Oleg Kiselev) Distribution: comp Organization: Quadratron Systems, Inc., Sherman Oaks, CA. Lines: 43 While playing the new robots game (posted recently to comp.sources.games), I discovered that the game would coredump when checking "safety" of a teleport destination. Not having much time to analyze the game, I put in a check for the validity of the examined location before a call to "move()" and it seemed to have fixed the problem. I am not sure if this is REALLY a correct fix, however, and there may be more places where bounds checking needs to be done. Just goes to show: always compile with "-g" and never strip your executables until you are REALLY sure... :-) *** good.c.orig Thu Aug 13 15:02:21 1987 --- good.c Thu Aug 13 15:03:43 1987 *************** *** 90,95 /* we are 2 steps out */ if( blocked(ty, tx, y, x)) continue; move(ty+y,tx+x); if ( abs(x) == 2 && abs(y) == 2 && inch() == FROBOT){ --- 90,99 ----- /* we are 2 steps out */ if( blocked(ty, tx, y, x)) continue; + if ((ty+y) < 0 || (tx+x) < 0 || (ty+y) > VERT + || (tx+x) > HORIZ) + continue; + move(ty+y,tx+x); if ( abs(x) == 2 && abs(y) == 2 && inch() == FROBOT){ -- Oleg Kiselev -- oleg@quad1.quad.com -- {...!psivax|seismo!gould}!quad1!oleg DISCLAIMER: All grammatical and spelling errors are inserted deliberately to test the software I am developing. In fact, that is the only reason I am posting. Yeah, that's the ticket! All my postings are just test data! Yeah!!