[dom media] Avoid a potential issue when assigning a media data buffer.

This commit is contained in:
Moonchild 2024-04-17 22:30:57 +02:00 committed by roytam1
commit 9eaee03eb4

View file

@ -106,8 +106,16 @@ public:
AlignedBuffer& operator=(AlignedBuffer&& aOther)
{
this->~AlignedBuffer();
new (this) AlignedBuffer(Move(aOther));
if (&aOther == this) {
return *this;
}
mData = aOther.mData;
mLength = aOther.mLength;
mBuffer = Move(aOther.mBuffer);
mCapacity = aOther.mCapacity;
aOther.mData = nullptr;
aOther.mLength = 0;
aOther.mCapacity = 0;
return *this;
}