You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
intQirTupleHeader::Release()
{
. . .
if (this->refCount == 0)
{
char* buffer = reinterpret_cast<char*>(this);
delete[] buffer; // Here the data pointed to by `this` gets deallocated. The `this` becomes a dangling pointer.
}
returnthis->refCount; // This has a risk of accessing the dangling pointer. Undefined Behavior.
}
Consider changing to
intQirTupleHeader::Release()
{
. . .
int32_t retVal = this->refCount; // Memorize in the local variable the `refCount`.if (this->refCount == 0)
{
char* buffer = reinterpret_cast<char*>(this);
delete[] buffer; // Here the data pointed to by `this` is deallocated. The `this` becomes a dangling pointer.
}
return retVal; // Access the local variable.
}
Consider also syncing the data type returned by int QirTupleHeader::Release() and type of this->refCount - int32_t.