Skip to content

Commit

Permalink
Fixed refcounting bug in new string implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Oct 21, 2014
1 parent 9323ae4 commit a9dcbfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 803 deletions.
27 changes: 15 additions & 12 deletions qtools/qcstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,19 +498,22 @@ class QCString
}
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;
}
Expand Down
Loading

0 comments on commit a9dcbfe

Please sign in to comment.