title: Why is VS2013 complaining about "using uninitialized memory"?
body: <p>I have a code that goes like this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  typedef struct {
      char *a;
      char *b;
      int c;
  } my_type;
  
  void free_my_type(my_type *p) {
      if (p) {
          if (p-&gt;a) free(p-&gt;a);  // line 12
          if (p-&gt;b) free(p-&gt;b);  // line 13
          free(p);
      }
  }
  
  int main(void) {
      my_type *p = malloc(sizeof(*p));
  
      p-&gt;a = malloc(10);
      p-&gt;b = malloc(10);
      p-&gt;c = 10;
  
      free_my_type(p);
  
      return 0;
  }
  </code></pre>
  
  <p>VS's Code Analysis is complaining that I am:</p>
  
  <pre><code>"C6001 Using uninitialized memory '*p'"
  
          '*p' is not initialized                             12
          Skip this branch, (assume 'p-&gt;b' is false)          13
          '*p' is used, but may not have been initialized     13
  </code></pre>
  
  <p>I mean, it's a pointer and I'm checking to see if it is <code>NULL</code>. How will I ever know if *p is initialized?</p>
  
  <p>Oddly enough, if there's only 1 other pointer inside the struct -- only <code>char *a</code>, for example -- the warning doesn't trigger. It also doesn't show up if I do <code>free(p-&gt;b)</code> before <code>free(p-&gt;a)</code> (swap lines 12 and 13).</p>