From 5f4f4e1cd64c7ceb0360dad7ebf2263238b35102 Mon Sep 17 00:00:00 2001 From: roam Date: Mon, 15 Apr 2002 17:27:34 +0000 Subject: Fix a segfault if 'wear' is used without an argument or with an argument that is not a valid word from the battlestar dictionary. PR: 36992 Submitted by: Ceri Davies Reviewed by: dd Approved by: dd, silence on -audit MFC after: 2 weeks --- games/battlestar/com2.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'games') diff --git a/games/battlestar/com2.c b/games/battlestar/com2.c index f8b0f38..d41d6037 100644 --- a/games/battlestar/com2.c +++ b/games/battlestar/com2.c @@ -51,13 +51,12 @@ wearit() /* synonyms = {sheathe, sheath} */ while(wordtype[++wordnumber] == ADJS); while(wordnumber <= wordcount){ value = wordvalue[wordnumber]; + if (value == -1) { + puts("Wear what?"); + return (firstnumber); + } for (n=0; objsht[value][n]; n++); switch(value){ - - case -1: - puts("Wear what?"); - return(firstnumber); - default: printf("You can't wear%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]); return(firstnumber); -- cgit v1.1