mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
enet: Fix a memory leak when peer:send fails (thanks pfirsich!)
This commit is contained in:
@@ -712,8 +712,14 @@ static int peer_send(lua_State *l) {
|
||||
ENetPacket *packet = read_packet(l, 2, &channel_id);
|
||||
|
||||
// printf("sending, channel_id=%d\n", channel_id);
|
||||
enet_peer_send(peer, channel_id, packet);
|
||||
return 0;
|
||||
int ret = enet_peer_send(peer, channel_id, packet);
|
||||
if (ret < 0) {
|
||||
enet_packet_destroy(packet);
|
||||
}
|
||||
|
||||
lua_pushinteger(l, ret);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct luaL_Reg enet_funcs [] = {
|
||||
|
||||
Reference in New Issue
Block a user