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

Add self-assignment cases in SocketAddress #56718

Open
wooffie opened this issue Jan 23, 2025 · 0 comments
Open

Add self-assignment cases in SocketAddress #56718

wooffie opened this issue Jan 23, 2025 · 0 comments

Comments

@wooffie
Copy link
Contributor

wooffie commented Jan 23, 2025

Version

20.18.0

Platform

any

Subsystem

src

What steps will reproduce the bug?

I think we can add check for self-assigment in ctors/assigment operators

memcpy(&address_, &addr.address_, addr.length());

Expect to see this:

SocketAddress& SocketAddress::operator=(const SocketAddress& addr) {
  if (this != &addr) {
    memcpy(&address_, &addr.address_, addr.length());
  }
  return *this;
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

Maybe not calling memcpy

What do you see instead?

Calling memcpy

Additional information

I wanna hear your opinion about this =)

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

No branches or pull requests

1 participant