public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/58415] New: __sso_string_base move constructor does not null terminate local data when moving from empty string
@ 2013-09-13 16:16 mkirzinger at gmail dot com
  2013-09-13 16:59 ` [Bug libstdc++/58415] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mkirzinger at gmail dot com @ 2013-09-13 16:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58415

            Bug ID: 58415
           Summary: __sso_string_base move constructor does not null
                    terminate local data when moving from empty string
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mkirzinger at gmail dot com

When doing a move construct using a sso_string_base versa_string where it is
moving from an empty string, the contents of the string it is moving from are
not copied, leaving the local data uninitialized (and later calling c_str() on
it may produce invalid output).

Code that demonstrates one of the situations this problem can show up (compile
with -std=c++11):

------------------------------------------
#include <ext/vstring.h>
#include <cstdio>

typedef __gnu_cxx::__versa_string<char> string;

int main(int argc, char* argv[])
{
    string s1("string");
    string s2("");
    std::swap(s1, s2);
    printf("%s%s\n", s1.c_str(), s2.c_str());
}
------------------------------------------

Expected output:
string
Actual output:
stringstring


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-09-13 18:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-13 16:16 [Bug libstdc++/58415] New: __sso_string_base move constructor does not null terminate local data when moving from empty string mkirzinger at gmail dot com
2013-09-13 16:59 ` [Bug libstdc++/58415] " paolo.carlini at oracle dot com
2013-09-13 17:26 ` mkirzinger at gmail dot com
2013-09-13 17:29 ` paolo.carlini at oracle dot com
2013-09-13 18:32 ` paolo at gcc dot gnu.org
2013-09-13 18:33 ` paolo at gcc dot gnu.org
2013-09-13 18:34 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).