Fix a bug in pstring.cpp causing crash if moved object is reused. (nw)

master
couriersud 2017-02-02 01:51:46 +01:00
parent ee8fed61c2
commit f61e1f2123
1 changed files with 10 additions and 7 deletions

View File

@ -415,16 +415,19 @@ static inline std::size_t countleadbits(std::size_t x)
template<typename F>
void pstring_t<F>::sfree(pstr_t *s)
{
bool b = s->dec_and_check();
if ( b && s != &m_zero)
if (s != nullptr)
{
if (stk != nullptr)
bool b = s->dec_and_check();
if ( b && s != &m_zero)
{
size_type sn= ((32 - countleadbits(s->len())) + 1) / 2;
stk[sn].push(s);
if (stk != nullptr)
{
size_type sn= ((32 - countleadbits(s->len())) + 1) / 2;
stk[sn].push(s);
}
else
plib::pfree_array(reinterpret_cast<char *>(s));
}
else
plib::pfree_array(reinterpret_cast<char *>(s));
}
}