Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 10839 invoked from network); 27 Oct 2005 22:28:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Oct 2005 22:28:22 -0000 Received: (qmail 78535 invoked by uid 500); 27 Oct 2005 22:28:22 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 78516 invoked by uid 500); 27 Oct 2005 22:28:22 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 78505 invoked by uid 500); 27 Oct 2005 22:28:21 -0000 Delivered-To: apmail-incubator-stdcxx-cvs@incubator.apache.org Received: (qmail 78502 invoked by uid 99); 27 Oct 2005 22:28:21 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 27 Oct 2005 15:28:21 -0700 Received: (qmail 10701 invoked by uid 65534); 27 Oct 2005 22:28:01 -0000 Message-ID: <20051027222801.10699.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r328966 - /incubator/stdcxx/trunk/include/istream.cc Date: Thu, 27 Oct 2005 22:28:00 -0000 To: stdcxx-cvs@incubator.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: sebor Date: Thu Oct 27 15:27:53 2005 New Revision: 328966 URL: http://svn.apache.org/viewcvs?rev=328966&view=rev Log: 2005-10-27 Martin Sebor STDCXX-59 * istream.cc (getline): On failure, stored the NUL character in the first location of the array as required by DR 243. Prevented the function from overwriting extracted data or storing the NUL character past the end of buffer. Modified: incubator/stdcxx/trunk/include/istream.cc Modified: incubator/stdcxx/trunk/include/istream.cc URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/istream.cc?rev=328966&r1=328965&r2=328966&view=diff ============================================================================== --- incubator/stdcxx/trunk/include/istream.cc (original) +++ incubator/stdcxx/trunk/include/istream.cc Thu Oct 27 15:27:53 2005 @@ -670,6 +670,12 @@ _RWSTD_ASSERT (!__n || __s); _RWSTD_ASSERT (0 != this->rdbuf ()); + if (0 < __n) { + // lwg issue 243: store the NUL character before + // constructing the sentry object in case it throws + traits_type::assign (__s [0], char_type ()); + } + const sentry __ipfx (*this, true /* noskipws */); ios_base::iostate __err = ios_base::goodbit; @@ -770,9 +776,9 @@ } } - traits_type::assign (__s [__n < 0 ? 0 : __n], char_type ()); - - if (!_C_gcount) + if (0 < _C_gcount) + traits_type::assign (__s [_C_gcount + 1], char_type ()); + else __err |= ios_base::failbit; if (__err)