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

Fix memory leak in peer_send if sending to non-"connected" peer #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pfirsich
Copy link

If the peer being sent to is not in the "connected" state, enet_peer_send will return -1 and the packet created by read_packet will not be freed.

I stumbled into this bug while I (foolishly) wrote this loop:

for peerIndex = 1, host:peer_count() do
    local peer = host:get_peer(peerIndex)
    if peer ~= event.peer then
        peer:send(event.data, channel, flag)
    end
end

In that way I find the documentation on host:get_peer a little bit confusing: "Returns the connected peer at the specified index", because get_peer may very well return non-"connected" peers. Should the documentation be adjusted as well in that regard?

If the peer being sent to is not in the "connected" state,
enet_peer_send will return -1 and the packet created by read_packet
will not be freed
…o enet2

The renaming is necessary so the new .dll can be imported in löve.
@pfirsich
Copy link
Author

Looking at this a long time after, I notice I did some other dumb stuff in my fork by accident, because I have forgotten this PR. Obviously it should only be this commit: 67f3073 I'm not interested in cleaning that up, but noticed it just now.

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

Successfully merging this pull request may close these issues.

1 participant