title: visual studio unallocted pointer not NULL
body: <p>I've encounter an issue in Visual Studio which drives me crazy.
  It is regarding unallocated pointers.</p>
  
  <p>I wanted to write a simple linked list app.The problem is that freed and unallocated pointers are not NULL which prevents me from iterating the list.</p>
  
  <p>Consider following C code</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;malloc.h&gt; 
  
  typedef struct _item
  {
      char data;
      struct _item * pNext;
  }item, *pItem;
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      pItem listHead;
      pItem listTemp;
      pItem listCurr;
  
      listHead = (pItem) malloc(sizeof(listHead));
      listHead-&gt;data = '0';
      listHead-&gt;pNext = NULL; //will create exception in free
  
      listTemp = listHead;
  
      while(listTemp-&gt;pNext != NULL) //issue 1
      {
          listTemp = listTemp-&gt;pNext;//0xfdfdfdfd - never NULL? how to check?
      }
  
      listCurr = (pItem) malloc(sizeof(listHead));
      listCurr-&gt;data = '1';
      listCurr-&gt;pNext = NULL; //will create exception in free
      listTemp-&gt;pNext = listCurr;
  
      listTemp = listHead;
      while(listTemp-&gt;pNext != NULL)  //issue 2
      {
          printf("%d ", listTemp-&gt;data - 48); //"0 "
          listTemp = listTemp-&gt;pNext;
      }
  
      printf("%d ", listTemp-&gt;data - 48);
      free(listTemp); //is set to oxfeeefee not to NULL?  //issue 3
  
  
      listTemp = listHead;
      while(listTemp-&gt;pNext != NULL)  //issue 4
      {
          listTemp = listTemp-&gt;pNext;
      }
  
      free(listTemp);//Not null?
  
      return 0;
  }
  </code></pre>
  
  <p>in line issue 1 and issue 2, listTemp->pNext is not NULL but 0xfdfdfdfd. This prevents from getting the last element in the list
  in line issue 3, free doesn't set the freed pointer to null but to 0xfeeefeee. This prevents me from getting last element again.</p>
  
  <p>How can i handle these issues?
  Thanks for help.</p>