Login
User Name:

Password:



Register

Forgot your password?
 Smaug muds with a Player Base
Jan 15, 2025 3:23 am
By EthanFinn
Array out of bounds ?
Jan 14, 2025 10:00 pm
By Samson
 AFKMud 2.5.0
Jan 14, 2025 3:27 pm
By Samson
time_update
Jan 12, 2025 9:53 pm
By Remcon
pwd memory leak
Jan 11, 2025 6:31 pm
By Samson
AFKMud 2.5.0
Author: AFKMud Team
Submitted by: Samson
SWFotEFUSS 1.5.2
Author: Various
Submitted by: Samson
SWRFUSS 1.4.2
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.6
Author: Various
Submitted by: Samson
AFKMud 2.2.5
Author: AFKMud Team
Submitted by: Samson
Users Online
Anthropic, Bytespider, Meta

Members: 0
Guests: 8
Stats
Files
Topics
Posts
Members
Newest Member
500
3,824
19,774
591
EthanFinn

» SmaugMuds » Codebases » SmaugFUSS » Array out of bounds ?
Forum Rules | Mark all | Recent Posts

Array out of bounds ?
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Jan 14, 2025 10:00 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,722
JoinedJan 1, 2002

 
I ran a static analysis recently with cppcheck and it picked this up as an out of bound array access in the first set of for loops here. Specifically with board->board[x][y] = 0;

I can't figure out why that would be the case. The compiler doesn't flag it, and it doesn't set off the sanitization code either.

static void init_board( GAME_BOARD_DATA * board )
{
   int x, y;

   for( x = 0; x < 8; x++ )
      for( y = 0; y < 8; y++ )
         board->board[x][y] = 0;

   board->board[0][0] = WHITE_ROOK;
   board->board[0][1] = WHITE_KNIGHT;
   board->board[0][2] = WHITE_BISHOP;
   board->board[0][3] = WHITE_QUEEN;
   board->board[0][4] = WHITE_KING;
   board->board[0][5] = WHITE_BISHOP;
   board->board[0][6] = WHITE_KNIGHT;
   board->board[0][7] = WHITE_ROOK;

   for( x = 0; x < 8; x++ )
      board->board[1][x] = WHITE_PAWN;
   for( x = 0; x < 8; x++ )
      board->board[6][x] = BLACK_PAWN;

   board->board[7][0] = BLACK_ROOK;
   board->board[7][1] = BLACK_KNIGHT;
   board->board[7][2] = BLACK_BISHOP;
   board->board[7][3] = BLACK_QUEEN;
   board->board[7][4] = BLACK_KING;
   board->board[7][5] = BLACK_BISHOP;
   board->board[7][6] = BLACK_KNIGHT;
   board->board[7][7] = BLACK_ROOK;
   board->player1 = NULL;
   board->player2 = NULL;
   board->turn = 0;
   board->type = TYPE_LOCAL;
}

Pages:<< prev 1 next >>