title: Access violation when passing BSTR string to _bstr_t or CComBSTR constructor
body: <p>I have BSTR string which is passed from COM server. When I put this string into _bstr_t (or CComBSTR) constructor then access violation is occurred. I checked this exception and found that this exception raised only when BSTR is empty (or null).</p>
  
  <p>I was trying to put nulled BSTR explicitly to _bstr_t constructor and this works fine:</p>
  
  <pre><code>BSTR bstr = NULL;
  _bstr_t t(bstr, false); 
  
  cout &lt;&lt; t.length() &lt;&lt; endl;
  </code></pre>
  
  <p>But with BSTR which is passed from COM server this don't work - access violation exception is ocurred when string is empty or null (or maybe corrupted?)</p>
  
  <p>I found that this workaround works fine:</p>
  
  <pre><code>if (SysStringLen(bstrFromCOMserver) &gt; 0) {
      _bstr_t t(bstrFromCOMserver, false);    
      cout &lt;&lt; t.length() &lt;&lt; endl;
  }
  </code></pre>
  
  <p>But I want to know why this don't work directly with _bstr_t or CComBSTR wrappers:</p>
  
  <pre><code>_bstr_t t(bstrFromCOMserver, false);
  if (t.length() &gt; 0) {...}
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>How COM server pass BSTR string:</p>
  
  <pre><code>void CALLBACK CProxy_ISTIQuoteEvents::OnSTIQuoteSnap(const structSTIQuoteSnap&amp; structQuoteSnap) const { 
          if (SysStringLen(structQuoteSnap.bstrUpdateTime) &gt; 0) {
              _bstr_t updateTime(structQuoteSnap.bstrUpdateTime, false);
          }
      }
  }
  </code></pre>