[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
gcc-bugzilla@gcc.gnu.org
Fri Sep 13 16:16:00 GMT 2013
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
More information about the Gcc-bugs
mailing list