From 9eaee03eb4bd7a8a00c135fb4b8c7b6a8e0c232b Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 17 Apr 2024 22:30:57 +0200 Subject: [PATCH] [dom media] Avoid a potential issue when assigning a media data buffer. --- dom/media/MediaData.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dom/media/MediaData.h b/dom/media/MediaData.h index 4fe8dbc5f2..5c1684fc6c 100644 --- a/dom/media/MediaData.h +++ b/dom/media/MediaData.h @@ -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; }