* Patch from pmaydell@chiark.greenend.org.uk to fix a segfault in

battlestar if you say "wear knfo" or similar nonsensical things.
     (Patch also sent upstream.) Closes: #70465


git-svn-id: file:///srv/svn/joey/bsdgames-trunk@5128 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
joey
2000-08-29 00:23:15 +00:00
parent 8fc65f19a3
commit ef972d8e76
3 changed files with 22 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
/* $NetBSD: com2.c,v 1.7 1998/08/24 00:22:45 hubertf Exp $ */
/* $NetBSD: com2.c,v 1.8 1999/07/14 17:42:13 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com2.c,v 1.7 1998/08/24 00:22:45 hubertf Exp $");
__RCSID("$NetBSD: com2.c,v 1.8 1999/07/14 17:42:13 hubertf Exp $");
#endif
#endif /* not lint */
@@ -54,12 +54,18 @@ wearit()
while (wordtype[++wordnumber] == ADJS);
while (wordnumber <= wordcount) {
value = wordvalue[wordnumber];
for (n = 0; objsht[value][n]; n++);
switch (value) {
case -1:
/* Is the thing being worn a known object? */
if (value == -1) {
puts("Wear what?");
return (firstnumber);
}
/* Now find the length of the short description,
* mostly so we know if it ends in 's' or not.
*/
for (n = 0; objsht[value][n]; n++)
/* do nothing */;
switch (value) {
default:
printf("You can't wear%s%s!\n", (objsht[value][n - 1] == 's' ? " " : " a "), objsht[value]);
@@ -301,7 +307,7 @@ int
follow()
{
if (followfight == ourtime) {
puts("The Dark Lord leaps away and runs down secret tunnels and corridoors.");
puts("The Dark Lord leaps away and runs down secret tunnels and corridors.");
puts("You chase him through the darkness and splash in pools of water.");
puts("You have cornered him. His laser sword extends as he steps forward.");
position = FINAL;