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 78198b6021
.
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.
This commit is contained in:
parent
8b9a92f794
commit
ced70ebaa3
1 changed files with 10 additions and 7 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue