Commit a9dcbfe2 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Fixed refcounting bug in new string implementation

parent 9323ae47
......@@ -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;
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment