{"id":381,"date":"2008-04-11T15:34:56","date_gmt":"2008-04-11T13:34:56","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=381"},"modified":"2008-04-11T15:34:56","modified_gmt":"2008-04-11T13:34:56","slug":"yet-another-atl-bug","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/381","title":{"rendered":"Yet another ATL bug"},"content":{"rendered":"<p>Another weird bug from Visual C++ .NET\/ATL internals (Visual Studio .NET 2003 Service Pack 1). <strong>IDispatch<\/strong> implementation (<strong>IModuleCommunicationTcp<\/strong> on the screenshot) supplied by Visual C++\u00a0 compiler that converts <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms221694(VS.85).aspx\">&#8220;by DISPID&#8221;<\/a> <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms221479(VS.85).aspx\"><strong>IDispatch::Invoke<\/strong><\/a> call into virtual method call (<strong>IModuleCommunicationTcp::get_HttpHost<\/strong>) does not initialize local BSTR variable <strong>i1<\/strong> on stack. In case of method failure (in which case there is no guarantee <strong>i1<\/strong> was properly initialized\/cleared) the code still uses the variable to initialize <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms697483(VS.85).aspx\">VARIANT<\/a>.<\/p>\n<p><a href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2008\/04\/11-image001-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-382\" title=\"Visual Studio .NET 2003 Screenshot\" src=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2008\/04\/11-image001-2-300x154.png\" alt=\"\" width=\"300\" height=\"154\" srcset=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2008\/04\/11-image001-2-300x154.png 300w, https:\/\/alax.info\/blog\/wp-content\/uploads\/2008\/04\/11-image001-2.png 1040w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In my case this caused resulting VARIANT (<a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ac97df2h(VS.71).aspx\">CComVariant<\/a>) contain .<strong>vt<\/strong> = <strong>VT_BSTR<\/strong>, .<strong>bstrVal<\/strong> = <strong>0x00000002<\/strong>, which is obviously incorrect and caused an access violation exception later in <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/ms221165(VS.85).aspx\">VariantClear<\/a> call.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another weird bug from Visual C++ .NET\/ATL internals (Visual Studio .NET 2003 Service Pack 1). IDispatch implementation (IModuleCommunicationTcp on the screenshot) supplied by Visual C++\u00a0 compiler that converts &#8220;by DISPID&#8221; IDispatch::Invoke call into virtual method call (IModuleCommunicationTcp::get_HttpHost) does not initialize local BSTR variable i1 on stack. In case of method failure (in which case there&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/381\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,21],"tags":[487,63,38,58],"class_list":["post-381","post","type-post","status-publish","format-standard","hentry","category-atl","category-seriously","tag-atl","tag-bug","tag-c","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=381"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/381\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}