summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabs <abs@NetBSD.org>2006-03-18 01:43:52 +0000
committerabs <abs@NetBSD.org>2006-03-18 01:43:52 +0000
commitcd327188bd11497debe9746d2191418a9f6a983f (patch)
tree8ef4be2333f43649ff5be6f7586d4e8cdab198a4
parent49b344a2eac8891a9543623de5335586dfd464f5 (diff)
downloadbsdgames-darwin-cd327188bd11497debe9746d2191418a9f6a983f.tar.gz
bsdgames-darwin-cd327188bd11497debe9746d2191418a9f6a983f.zip
If none of the boarding parties are set do not fall off the end of the
list. Addresses Coverity CID 1507. Also put pointers before shorts in a struct rather than mixing them up
-rw-r--r--sail/extern.h4
-rw-r--r--sail/pl_5.c6
2 files changed, 5 insertions, 5 deletions
diff --git a/sail/extern.h b/sail/extern.h
index f2288406..164e852e 100644
--- a/sail/extern.h
+++ b/sail/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.27 2004/02/08 00:32:48 jsm Exp $ */
+/* $NetBSD: extern.h,v 1.28 2006/03/18 01:43:52 abs Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -148,8 +148,8 @@ struct logs {
};
struct BP {
- short turnsent;
struct ship *toship;
+ short turnsent;
short mensent;
};
diff --git a/sail/pl_5.c b/sail/pl_5.c
index b3bdd77a..d19fc407 100644
--- a/sail/pl_5.c
+++ b/sail/pl_5.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl_5.c,v 1.17 2004/11/05 21:30:32 dsl Exp $ */
+/* $NetBSD: pl_5.c,v 1.18 2006/03/18 01:43:52 abs Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: pl_5.c,v 1.17 2004/11/05 21:30:32 dsl Exp $");
+__RCSID("$NetBSD: pl_5.c,v 1.18 2006/03/18 01:43:52 abs Exp $");
#endif
#endif /* not lint */
@@ -218,7 +218,7 @@ parties(struct ship *to, int *crew, int isdefense, int buf)
ptr = isdefense ? to->file->DBP : to->file->OBP;
for (j = 0; j < NBP && ptr[j].turnsent; j++)
;
- if (!ptr[j].turnsent && buf > '0') {
+ if (j < NBP && !ptr[j].turnsent && buf > '0') {
men = 0;
for (k = 0; k < 3 && buf > '0'; k++) {
men += crew[k]