From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1569 invoked by alias); 13 Sep 2013 17:26:44 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 1533 invoked by uid 48); 13 Sep 2013 17:26:39 -0000 From: "mkirzinger at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/58415] __sso_string_base move constructor does not null terminate local data when moving from empty string Date: Fri, 13 Sep 2013 17:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mkirzinger at gmail dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: paolo.carlini at oracle dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-09/txt/msg01005.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58415 --- Comment #2 from Michael Kirzinger --- There appears to be one additional problem: if __rcs._M_is_local() is true, but __rcs._M_length() is false, the buffer of the string being created is never null terminated/zeroed. Example: ---------------------------------------------------------- #include #include #include #include typedef __gnu_cxx::__versa_string string; int main() { char buf[sizeof(string)+1] = "stringstringstring"; string s1; string* s2 = new (buf) string(std::move(s1)); printf("%s\n", s2->c_str()); }