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
This commit is contained in:
abs 2006-03-18 01:43:52 +00:00
parent de119fc4bd
commit a3edf3e145
2 changed files with 5 additions and 5 deletions

View File

@ -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 * Copyright (c) 1983, 1993
@ -148,8 +148,8 @@ struct logs {
}; };
struct BP { struct BP {
short turnsent;
struct ship *toship; struct ship *toship;
short turnsent;
short mensent; short mensent;
}; };

View File

@ -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 * Copyright (c) 1983, 1993
@ -34,7 +34,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
#else #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
#endif /* not lint */ #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; ptr = isdefense ? to->file->DBP : to->file->OBP;
for (j = 0; j < NBP && ptr[j].turnsent; j++) 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; men = 0;
for (k = 0; k < 3 && buf > '0'; k++) { for (k = 0; k < 3 && buf > '0'; k++) {
men += crew[k] men += crew[k]