Skip to content

Commit

Permalink
Fix possible use after free warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sashashura committed Nov 19, 2023
1 parent fa2fab5 commit 089704f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Packet++/header/TLVData.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ namespace pcpp
/**
* Free the memory of the TLV record raw data
*/
void purgeRecordData() { if (!isNull()) delete [] m_Data; }
void purgeRecordData()
{
if (!isNull())
{
delete [] m_Data;
m_Data = nullptr;
}
}

/**
* A templated method to retrieve the record data as a certain type T. For example, if record data is 4B long
Expand Down

0 comments on commit 089704f

Please sign in to comment.