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

Memory leak #1

Closed
Gerrit0 opened this issue May 12, 2024 · 2 comments
Closed

Memory leak #1

Gerrit0 opened this issue May 12, 2024 · 2 comments

Comments

@Gerrit0
Copy link

Gerrit0 commented May 12, 2024

CheeseShop &operator=(CheeseShop &&other) noexcept {
inventory = std::move(other.inventory);
clerkName = other.clerkName;
other.clerkName = nullptr;

This code has a memory leak if I have a CheeseShop which already has a clerkName pointer

It'd be better to use a std::unique_ptr here, though I get why you didn't given the subject of your post... raw pointers are almost always a bad idea.

@pboyd
Copy link
Owner

pboyd commented May 12, 2024 via email

pboyd added a commit that referenced this issue May 14, 2024
@pboyd
Copy link
Owner

pboyd commented May 14, 2024

This has been fixed. Thanks again.

@pboyd pboyd closed this as completed May 14, 2024
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

2 participants