From f61e1f212379f581daadaff8fc10107b8f9849f5 Mon Sep 17 00:00:00 2001 From: couriersud Date: Thu, 2 Feb 2017 01:51:46 +0100 Subject: [PATCH] Fix a bug in pstring.cpp causing crash if moved object is reused. (nw) --- src/lib/netlist/plib/pstring.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lib/netlist/plib/pstring.cpp b/src/lib/netlist/plib/pstring.cpp index baeace1edb9..3369f23b6e2 100644 --- a/src/lib/netlist/plib/pstring.cpp +++ b/src/lib/netlist/plib/pstring.cpp @@ -415,16 +415,19 @@ static inline std::size_t countleadbits(std::size_t x) template void pstring_t::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(s)); } - else - plib::pfree_array(reinterpret_cast(s)); } }