diff options
author | christos <christos@NetBSD.org> | 2006-03-19 00:19:31 +0000 |
---|---|---|
committer | christos <christos@NetBSD.org> | 2006-03-19 00:19:31 +0000 |
commit | 0521c7bab72728f9b578d28a6f3fe39f1503d25b (patch) | |
tree | 52bbd3b70ab86870bd29ec53f7adac9a1c11b28c /monop/houses.c | |
parent | 0fab94e3a9f8b9f534a187389379c1028e7539f6 (diff) | |
download | bsdgames-darwin-0521c7bab72728f9b578d28a6f3fe39f1503d25b.tar.gz bsdgames-darwin-0521c7bab72728f9b578d28a6f3fe39f1503d25b.tar.zst bsdgames-darwin-0521c7bab72728f9b578d28a6f3fe39f1503d25b.zip |
Coverity CID 998: Possible NULL pointer deref. Actually this was a bug
where a house to be sold would be skipped. Change the sell loop to be like
the buy side loop.
Diffstat (limited to 'monop/houses.c')
-rw-r--r-- | monop/houses.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/monop/houses.c b/monop/houses.c index 980f784a..403d0887 100644 --- a/monop/houses.c +++ b/monop/houses.c @@ -1,4 +1,4 @@ -/* $NetBSD: houses.c,v 1.8 2004/01/27 20:30:30 jsm Exp $ */ +/* $NetBSD: houses.c,v 1.9 2006/03/19 00:19:31 christos Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)houses.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: houses.c,v 1.8 2004/01/27 20:30:30 jsm Exp $"); +__RCSID("$NetBSD: houses.c,v 1.9 2006/03/19 00:19:31 christos Exp $"); #endif #endif /* not lint */ @@ -177,7 +177,7 @@ sell_houses() over: num_mon = 0; good = TRUE; - for (op = cur_p->own_list; op; op = op->next) + for (op = cur_p->own_list; op;) if (op->sqr->type == PRPTY && op->sqr->desc->monop) { mp = op->sqr->desc->mon_desc; names[num_mon] = (monops[num_mon]=mp)->name; @@ -187,10 +187,11 @@ over: if (!good && op->sqr->desc->houses != 0) good++; while (op->next && op->sqr->desc->mon_desc == mp - && (op=op->next)); + && (op = op->next)); if (!good) --num_mon; - } + } else + op = op->next; if (num_mon == 0) { printf("You don't have any houses to sell!!\n"); return; |