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

@ -414,6 +414,8 @@ 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)
{
if (s != nullptr)
{ {
bool b = s->dec_and_check(); bool b = s->dec_and_check();
if ( b && s != &m_zero) if ( b && s != &m_zero)
@ -427,6 +429,7 @@ void pstring_t<F>::sfree(pstr_t *s)
plib::pfree_array(reinterpret_cast<char *>(s)); plib::pfree_array(reinterpret_cast<char *>(s));
} }
} }
}
template<typename F> template<typename F>
pstr_t *pstring_t<F>::salloc(std::size_t n) pstr_t *pstring_t<F>::salloc(std::size_t n)