title: Why AddressSanitizer report wild pointer as a heap-buffer-overflow instead of use-after-free
body: <pre><code>class ISettingChangedListener
  {
  public:
      virtual void NotifySettingsChanged() = 0;
  };
  
  class View : public ISettingChangedListener {
      // ...
  }
  
  // Set the listener as a pointer to a view
  void System::SetListener(ISettingChangedListener *listener) {
      m_settings_changed_listener = listener;
  }
  
  // view is destroyed somewhere by delete
  
  // after a while when the settings is about to change
  
  void System::ChangeSettings() {
      // do some modify
      m_settings_changed_listener-&gt;NotifySettingsChanged(); // report a heap-over-flow instead of use-after-free
  }
  </code></pre>
  
  <p>The code flow is comment above. Is it because that the freed memory get reallocated by other code or something else ?</p>
  
  <p>Another test code result in <code>use-after-free</code> when <code>NotifySettingsChanged</code> get called immediately after the <code>View object</code> is deleted.</p>