diff options
author | 2017-02-02 01:51:46 +0100 | |
---|---|---|
committer | 2017-02-05 17:19:50 +0100 | |
commit | f61e1f212379f581daadaff8fc10107b8f9849f5 (patch) | |
tree | 207be4fba8fc01d87b0bb23e92d5ca9e71c964dd /src/lib/netlist/plib/pstring.cpp | |
parent | ee8fed61c22fa746cd6370315ae4e86971702c56 (diff) |
Fix a bug in pstring.cpp causing crash if moved object is reused. (nw)
Diffstat (limited to 'src/lib/netlist/plib/pstring.cpp')
-rw-r--r-- | src/lib/netlist/plib/pstring.cpp | 17 |
1 files 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<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)); } } |