Skip to content

Add self-assignment cases in SocketAddress #56718

Description

@wooffie

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 =)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions