From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id D1176398682A for ; Tue, 10 Nov 2020 19:41:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D1176398682A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-248-fgsGtWORPoS5eiZ46KEaGA-1; Tue, 10 Nov 2020 14:41:20 -0500 X-MC-Unique: fgsGtWORPoS5eiZ46KEaGA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C701B8049CA; Tue, 10 Nov 2020 19:41:19 +0000 (UTC) Received: from localhost (unknown [10.33.36.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7317710013D0; Tue, 10 Nov 2020 19:41:19 +0000 (UTC) Date: Tue, 10 Nov 2020 19:41:18 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Fix more unspecified comparisons to null pointer [PR 97415] Message-ID: <20201110194118.GA4187555@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 19:41:25 -0000 --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This adds some more null checks to avoid a relational comparison with a null pointer, similar to 78198b6021a9695054dab039340202170b88423c. libstdc++-v3/ChangeLog: PR libstdc++/97415 * include/std/sstream (basic_stringbuf::_M_update_egptr) (basic_stringbuf::__xfer_bufptrs::__xfer_bufptrs): Check for null before comparing pointers. Tested powerpc64le-linux. Committed to trunk. --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit ced70ebaa372945ec8d73703d81e4a10d6d51c9b Author: Jonathan Wakely Date: Tue Nov 10 15:46:02 2020 libstdc++: Fix more unspecified comparisons to null pointer [PR 97415] This adds some more null checks to avoid a relational comparison with a null pointer, similar to 78198b6021a9695054dab039340202170b88423c. libstdc++-v3/ChangeLog: PR libstdc++/97415 * include/std/sstream (basic_stringbuf::_M_update_egptr) (basic_stringbuf::__xfer_bufptrs::__xfer_bufptrs): Check for null before comparing pointers. diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream index 437e2ba2a5f8..9c50e4e83281 100644 --- a/libstdc++-v3/include/std/sstream +++ b/libstdc++-v3/include/std/sstream @@ -357,13 +357,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 void _M_update_egptr() { - const bool __testin = _M_mode & ios_base::in; - if (this->pptr() && this->pptr() > this->egptr()) + if (char_type* __pptr = this->pptr()) { - if (__testin) - this->setg(this->eback(), this->gptr(), this->pptr()); - else - this->setg(this->pptr(), this->pptr(), this->pptr()); + char_type* __egptr = this->egptr(); + if (!__egptr || __pptr > __egptr) + { + if (_M_mode & ios_base::in) + this->setg(this->eback(), this->gptr(), __pptr); + else + this->setg(__pptr, __pptr, __pptr); + } } } @@ -396,7 +399,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 _M_poff[0] = __from.pbase() - __str; _M_poff[1] = __from.pptr() - __from.pbase(); _M_poff[2] = __from.epptr() - __str; - if (__from.pptr() > __end) + if (!__end || __from.pptr() > __end) __end = __from.pptr(); } --gBBFr7Ir9EOA20Yy--