Boost C++ Libraries: Ticket #4286: regex - making a pointer to an invalid dereferenced iterator. https://svn.boost.org/trac10/ticket/4286 <p> in function w32_transform in libs/regex/src/w32_regex_traits.cpp </p> <p> LCMapStringA() is called with parameter &amp;*result.begin() </p> <p> In this case the std::string is created with std::string result(++bytes, '\0'), so I would have thought that *result.begin() would return result.end() as the length of the string is zero, even though a chunk of memory has been allocated. </p> <p> In my case, the iterator returns 0xccccccc and the subsequent LCMapStringA() call fails spectacularly in debug mode. </p> <p> I have _HAS_ITERATOR_DEBUGGING and _SECURE_SCL turned off. </p> <p> I switched to using &amp;(result<a class="missing changeset" title="No changeset 0 in the repository">[0]</a>) instead and that was fine. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4286 Trac 1.4.3 John Maddock Fri, 04 Jun 2010 16:14:11 GMT <link>https://svn.boost.org/trac10/ticket/4286#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4286#comment:1</guid> <description> <p> The code should be correct: it creates a string that is ++bytes long and consists entirely of the null character. So begin() != end(). </p> <p> I can't reproduce this here, can you let me have a self contained test case? </p> <p> Also can you check that you're not mixing different values for _HAS_ITERATOR_DEBUGGING and _SECURE_SCL in different translation units (for example in your source and the regex lib). Doing this will cause strange failures like this to occur. </p> <p> HTH, John. </p> </description> <category>Ticket</category> </item> <item> <author>CharlesPenny@…</author> <pubDate>Mon, 07 Jun 2010 13:07:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4286#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4286#comment:2</guid> <description> <p> I am mixing different values for _HAS_ITERATOR_DEBUGGING and _SECURE_SCL in different translation units (which is the basic problem). I think my code change is working as it is avoiding the use of iterators. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Mon, 07 Jun 2010 23:58:54 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4286#comment:3 https://svn.boost.org/trac10/ticket/4286#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket