title: Conditional jump or move depends on uninitialised value(s)
body: <p>I've been struggling with this problem for a while now, searching every possible solution. I'm new to C so I'ts hard. I know I have some variable uninitialized, but I can't find them. I am trying to print a matrix. Here's the constructor:</p>
  
  <pre><code>BoardP createNewBoard(int width, int high)
  {  
  
      BoardP board = (BoardP) malloc(sizeof(Board));
  
      if (board == NULL)
      {
          reportError(MEM_OUT);
          return NULL;
      }
      board-&gt;height = high;
      board-&gt;width = width;
      board-&gt;board = (char**) malloc(high * sizeof(char*));
      int i;
      for (i=0; i&lt;high; i++)
      {
          board-&gt;board[i] = (char*) malloc(width * sizeof(char));
          if (board-&gt;board[i] == NULL)
          {
              freeTempBoard(board,i);
              return NULL;
          }
      }
  
      return board;
  }
  </code></pre>
  
  <p>The constructor returns BoardP, a pinter to Board, which is:</p>
  
  <pre><code>typedef struct Board
  {
      int width;
      int height;
      char **board;
  } Board;
  </code></pre>
  
  <p>Now I fail trying to print the board->board. I loop over the matrix and for each cell I call this function:</p>
  
  <pre><code>static void printChar(ConstBoardP board, int X, int Y)
  {
      if (X&gt;=board-&gt;height || Y&gt;=board-&gt;width)
      {
          printf(" ");
      }
      else
      {
          printf("%c ",board-&gt;board[X][Y]); //!!THIS IS LINE 299 IN Board.c!!
      }
  }
  </code></pre>
  
  <p>And fianlly here's the error I get:</p>
  
  <pre><code>==4931== Conditional jump or move depends on uninitialised value(s)
  ==4931==    at 0x4E973D9: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:880)
  ==4931==    by 0x4E6F01B: vfprintf (vfprintf.c:1614)
  ==4931==    by 0x4E75879: printf (printf.c:35)
  ==4931==    by 0x400D91: printChar (Board.c:299)
  ==4931==    by 0x400CED: printBoard (Board.c:284)
  ==4931==    by 0x400F1A: main (PlayBoard.c:19)
  ==4931== 
  ==4931== Conditional jump or move depends on uninitialised value(s)
  ==4931==    at 0x4E97401: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:887)
  ==4931==    by 0x4E6F01B: vfprintf (vfprintf.c:1614)
  ==4931==    by 0x4E75879: printf (printf.c:35)
  ==4931==    by 0x400D91: printChar (Board.c:299)
  ==4931==    by 0x400CED: printBoard (Board.c:284)
  ==4931==    by 0x400F1A: main (PlayBoard.c:19)
  ==4931== 
  ==4931== Conditional jump or move depends on uninitialised value(s)
  ==4931==    at 0x4E6F025: vfprintf (vfprintf.c:1614)
  ==4931==    by 0x4E75879: printf (printf.c:35)
  ==4931==    by 0x400D91: printChar (Board.c:299)
  ==4931==    by 0x400CED: printBoard (Board.c:284)
  ==4931==    by 0x400F1A: main (PlayBoard.c:19)
  </code></pre>
  
  <p>Now there's another file that calls createNewBoard, and then create printBoard(newBoard,0,0). The only thing that could possibly be uninitialized is board->board, other then that I have no ideas. I don't know how to debug it.
  I know its a lot of text, but I can't find the problem. Any idea would be much appreciated </p>