title: Reallocate a 2d char array
body: <p>I have following code</p>
  
  <pre><code> int wordLenght = 256, arrayLength = 2, i = 0, counter = 0;
   char **stringArray = NULL; 
  
   stringArray = calloc(arrayLength, sizeof(*stringArray));
  
   for(counter; counter&lt;wordLenght; counter++) 
      stringArray[counter] = calloc(wordLenght, sizeof(stringArray));
  
   while(1)
   {
     printf("Input: ");
     fgets(stringArray[i], wordLenght, stdin);
  
     printf("stringArray[%d]: %s\n", i, stringArray[i]);
  
     if(i == arrayLength)
     {
       printf("Reallocation !!!\n");
       arrayLength *= 2;
  
       stringArray = realloc(stringArray, arrayLength*sizeof(*stringArray));
  
     } 
  
     i++;
   }    
  </code></pre>
  
  <p>I get this reallocation error:</p>
  
  <pre><code>*** glibc detected *** ./stringArray: realloc(): invalid next size: 0x0000000000b49010 ***
  ======= Backtrace: =========
  /lib/libc.so.6(+0x775b6)[0x7f4dd12565b6]
  /lib/libc.so.6(+0x7dd66)[0x7f4dd125cd66]
  /lib/libc.so.6(realloc+0xf0)[0x7f4dd125d080]
  ./stringArray[0x4007f9]
  /lib/libc.so.6(__libc_start_main+0xfd)[0x7f4dd11fdc4d]
  ./stringArray[0x400629]
  </code></pre>
  
  <p>What's my problem here ???</p>
  
  <p>Thanks, greets </p>