title: Using pointer after free()
body: <p>During my tests, I have found that it is possible to use pointer after free(). I have the following code:</p>
  
  <pre><code>typedef struct{
  
      int module_id;
      int adc_id;
      struct config_line * pnext;
  
  } config_line;
  config_line * create_list()
  {
  
  config_line * phead = (config_line *) malloc(sizeof(config_line));
  phead-&gt;pnext=NULL;
  phead-&gt;module_id = 1;
  phead-&gt;adc_id = 2;
  
  printf("module_id=%d adc_id=%d\n",phead-&gt;module_id, phead-&gt;adc_id);
  
  free(phead);
  
  printf("module_id=%d adc_id=%d\n",phead-&gt;module_id, phead-&gt;adc_id);
  
  phead-&gt;module_id = 2;
  phead-&gt;adc_id = 5;
  
  printf("module_id=%d adc_id=%d\n",phead-&gt;module_id, phead-&gt;adc_id);
  }
  </code></pre>
  
  <p>The output of this code is:</p>
  
  <pre><code>module_id=1 adc_id=2
  module_id=0 adc_id=2
  module_id=2 adc_id=5
  </code></pre>
  
  <p>Why after free(phead) I can get access (read and write) to pointer? Why there is not segmentation fault?</p>