mirror of
https://review.haiku-os.org/haiku
synced 2025-01-20 05:21:28 +01:00
libnetapi: Fix use after free
Fix 'fImpl' is used after delete in BNetBuffer::operator= (GetImpl() returns fImpl), when it is used with self assignment. Pointed out by Clang Static Analyzer. Change-Id: Ic80a4ce73879062581b9241f84a4340919d281b9 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3393 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
a756a8ad1b
commit
6c016dc54a
@ -66,12 +66,13 @@ BNetBuffer::BNetBuffer(BMessage* archive) :
|
||||
BNetBuffer&
|
||||
BNetBuffer::operator=(const BNetBuffer& buffer)
|
||||
{
|
||||
delete fImpl;
|
||||
|
||||
fImpl = new (std::nothrow) DynamicBuffer(*buffer.GetImpl());
|
||||
if (fImpl != NULL)
|
||||
fInit = fImpl->InitCheck();
|
||||
if (&buffer != this) {
|
||||
delete fImpl;
|
||||
|
||||
fImpl = new (std::nothrow) DynamicBuffer(*buffer.GetImpl());
|
||||
if (fImpl != NULL)
|
||||
fInit = fImpl->InitCheck();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user