Bug 1603714: Add explicit copy constructor and copy assignment operators to nt::MemorySectionNameBuf; r=mhowell

Differential Revision: https://phabricator.services.mozilla.com/D57889

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Aaron Klotz 2019-12-19 22:11:24 +00:00
parent a3f185ef1b
commit 72918a2e58

View File

@ -240,6 +240,23 @@ struct MemorySectionNameBuf : public _MEMORY_SECTION_NAME {
mSectionFileName.Buffer = mBuf;
}
MemorySectionNameBuf(const MemorySectionNameBuf& aOther) {
*this = aOther;
}
// We cannot use default copy here because mSectionFileName.Buffer needs to
// be updated to point to |this->mBuf|, not |aOther.mBuf|.
MemorySectionNameBuf& operator=(const MemorySectionNameBuf& aOther) {
mSectionFileName.Length = aOther.mSectionFileName.Length;
mSectionFileName.MaximumLength = sizeof(mBuf);
mSectionFileName.Buffer = mBuf;
memcpy(mBuf, aOther.mBuf, aOther.mSectionFileName.Length);
return *this;
}
MemorySectionNameBuf(MemorySectionNameBuf&&) = delete;
MemorySectionNameBuf& operator=(MemorySectionNameBuf&&) = delete;
// Native NT paths, so we can't assume MAX_PATH. Use a larger buffer.
WCHAR mBuf[2 * MAX_PATH];