summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-10-01 20:55:41 +0000
committerJens Arnold <amiconn@rockbox.org>2006-10-01 20:55:41 +0000
commitd72506cf985e86610ad3b2dd88bbde8be6dc2428 (patch)
treea467909b5c4f88ce72188cc85e7fce6dd9de935c /apps/plugins
parentf3fc9cbd8b66ad97ff5be78c8adc9e7aeccdc328 (diff)
downloadrockbox-d72506cf985e86610ad3b2dd88bbde8be6dc2428.zip
rockbox-d72506cf985e86610ad3b2dd88bbde8be6dc2428.tar.gz
rockbox-d72506cf985e86610ad3b2dd88bbde8be6dc2428.tar.bz2
rockbox-d72506cf985e86610ad3b2dd88bbde8be6dc2428.tar.xz
Solitaire: Fixed incorrect condition check that caused an out-of-bounds access allowing to put the 2 of spades into nirvana.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11104 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/solitaire.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index dd3efda..9353313 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -866,31 +866,40 @@ enum move move_card( int dest_col, int src_card )
}
/* if we are on one of the 4 final stacks ... */
else if( dest_col < REM_COL )
- {
- /* ... check if we are on an empty stack, that the src is an
- * ace and that this is the good final stack */
- if( dest_card == NOT_A_CARD
- && deck[src_card].num == 0
- && deck[src_card].suit == dest_col - STACKS_COL )
- {
- /* this is a winning combination */
- stacks[dest_col - STACKS_COL] = src_card;
- }
- /* ... or check if the cards follow one another, have the same
- * suit and {that src has no .next element or is from the remains'
- * stack} */
- else if( deck[dest_card].suit == deck[src_card].suit
- && deck[dest_card].num + 1 == deck[src_card].num
- && (deck[src_card].next == NOT_A_CARD || src_col == REM_COL) )
+ {
+ /* ... check if we are on an empty stack... */
+ if( dest_card == NOT_A_CARD )
{
- /* this is a winning combination */
- deck[dest_card].next = src_card;
+ /* ... and the src is an ace and this is the correct final stack */
+ if( deck[src_card].num == 0
+ && deck[src_card].suit == dest_col - STACKS_COL )
+ {
+ /* this is a winning combination */
+ stacks[dest_col - STACKS_COL] = src_card;
+ }
+ else
+ {
+ /* this is not a winning combination */
+ return MOVE_NOT_OK;
+ }
}
- /* ... or, well that's not good news */
- else
+ else /* non-empty stack */
{
- /* this is not a winning combination */
- return MOVE_NOT_OK;
+ /* ...check if the cards follow one another, have the same suit and
+ * {that src has no .next element or is from the remains' stack} */
+ if( deck[dest_card].suit == deck[src_card].suit
+ && deck[dest_card].num + 1 == deck[src_card].num
+ && (deck[src_card].next == NOT_A_CARD || src_col == REM_COL) )
+ {
+ /* this is a winning combination */
+ deck[dest_card].next = src_card;
+ }
+ /* ... or, well that's not good news */
+ else
+ {
+ /* this is not a winning combination */
+ return MOVE_NOT_OK;
+ }
}
}
/* if we are on the remains' stack */