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

This commit is contained in:
couriersud 2017-02-02 01:51:46 +01:00
parent ee8fed61c2
commit f61e1f2123

View File

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