KPath: Prevent setting a KPath to itself causing use-after-free.
SetTo frees the buffer before setting it to the new one, but if KPath sets itself to ... itself, then it will of course try to access the buffer again. Spotted by clang-analyzer (amidst quite a few false positives, so this doesn't seem like an especially good rabbit hole to go down right now.)
This commit is contained in:
@@ -356,6 +356,9 @@ KPath::Normalize(bool traverseLeafLink)
|
||||
KPath&
|
||||
KPath::operator=(const KPath& other)
|
||||
{
|
||||
if (other.fBuffer == fBuffer)
|
||||
return *this;
|
||||
|
||||
SetTo(other.fBuffer, fLazy ? KPath::LAZY_ALLOC : KPath::DEFAULT,
|
||||
other.fBufferSize);
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user