diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2014-10-21 19:31:35 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2014-10-21 19:31:35 (GMT) |
commit | a9dcbfe28625673f4d13bc5b3cde694c24062e19 (patch) | |
tree | 978138b6c6ba28a6e62a6dd9cfb0f5e2a6de6391 /qtools/qcstring.h | |
parent | 9323ae470ad514586706dc8647501361fe208f36 (diff) | |
download | Doxygen-a9dcbfe28625673f4d13bc5b3cde694c24062e19.zip Doxygen-a9dcbfe28625673f4d13bc5b3cde694c24062e19.tar.gz Doxygen-a9dcbfe28625673f4d13bc5b3cde694c24062e19.tar.bz2 |
Fixed refcounting bug in new string implementation
Diffstat (limited to 'qtools/qcstring.h')
-rw-r--r-- | qtools/qcstring.h | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/qtools/qcstring.h b/qtools/qcstring.h index 7170455..5c3a0de 100644 --- a/qtools/qcstring.h +++ b/qtools/qcstring.h @@ -498,19 +498,22 @@ public: } StringRep &operator=(const StringRep &s) { - if (!u.s.isShort) - { - u.l.d->dispose(); - } - if (s.u.s.isShort) // copy by value - { - u.s = s.u.s; - } - else // copy by reference + if (&s!=this) { - u.l.isShort=FALSE; - u.l.d = s.u.l.d; - u.l.d->refCount++; + if (!u.s.isShort) + { + u.l.d->dispose(); + } + if (s.u.s.isShort) // copy by value + { + u.s = s.u.s; + } + else // copy by reference + { + u.l.isShort=FALSE; + u.l.d = s.u.l.d; + u.l.d->refCount++; + } } return *this; } |