Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RawPacket::copyDataFrom will have a memory-leak if instance owns its m_RawData, otherwise the length might not match #1627

Open
Elgu opened this issue Oct 30, 2024 · 1 comment
Labels

Comments

@Elgu
Copy link

Elgu commented Oct 30, 2024

void RawPacket::copyDataFrom(const RawPacket& other, bool allocateData)

There are actually two issues:

  1. If allocateData is set, m_RawData is overwritten without checking if delete[] has to be called first
  2. If allocateData is not set, the data from other is memcpied without checking whether m_RawData points to a buffer of sufficient size
@seladb
Copy link
Owner

seladb commented Nov 4, 2024

RawPacket::copyDataFrom() is a private method that is not exposed to the user. It expects the caller to perform these checks. The only relevant place is operator= which calls it with allocateData=true, but it deletes the data first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants