title: Assignment to variable gives segmentation fault in completely unrelated function
body: <p>I copied some code that simply reads a file to a string and prints the string from an older program. It was working fine, so I decided to modify it a bit. The new program is</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main() {
      FILE *itemlist = fopen("itemlist", "r");
      char *currentstring, charbuffer[2];
      // char itemstart = 0;
      while (fgets(charbuffer, 2, itemlist)) {
          strcat(currentstring, charbuffer);
      }
      printf("%s", currentstring);
      return 0; 
  }
  </code></pre>
  
  <p>And it works as expected. But when I uncomment the <code>itemstart</code> line, it gives a segmentation fault. I'm not even using it and as far as I'm concerned, initializing an char to 0 is not illegal. I thought it was an issue with types, then I changed it to a short and then to int and it was still giving a segfault.</p>
  
  <p>But then I removed the <code>= 0</code> part and it worked again. Then I decided to put it back, debug the binary with gdb, and the segfault was at <code>strcat</code>.</p>
  
  <p>How is this possible?</p>