title: Valgrind invalid read of size 8 when printing out a character array
body: <p>I am trying to print out an array of characters, but valgrind is giving an invalid read message when I try to print out the lines. Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  void printLines (char *ptArray[]);
  char line1[] = "black yummy wolfberry";
  char line2[] = "Nate is cute";
  char line3[] = "hi there friend";
  char line4[] = "abcd";
  
  int main(int argc, char *argv[]){
    char **ptArray = calloc(4, sizeof(char *)); // Line 28 when calling calloc
    ptArray[0] = line1;
    ptArray[1] = line2;
    ptArray[2] = line3;
    ptArray[3] = line4;
  
    printLines(ptArray); // Line 34 when printLines is called
  
    free(ptArray);
    return 0;
  }
  
  void printLines (char *ptArray[]){
    char **a = ptArray;
    while(*a != NULL){   // Line 232 when invalid read occurs
      printf("%s\n", *a);
      a++;
    }
  }  
  </code></pre>
  
  <p>Here is the error message:</p>
  
  <pre><code>==12029== Invalid read of size 8
  ==12029==    at 0x40110C: printLines (textsort2.c:232)
  ==12029==    by 0x4008F2: main (textsort2.c:36)
  ==12029==  Address 0x5204060 is 0 bytes after a block of size 32 alloc'd
  ==12029==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==12029==    by 0x400883: main (textsort2.c:28)
  </code></pre>
  
  <p>Anybody knows how to fix this? I appreciate all your help!</p>