Skip to content

Commit

Permalink
Fixed lua reference leak when reopening a socket directly after closi…
Browse files Browse the repository at this point in the history
…ng it
  • Loading branch information
FredyH committed Jun 24, 2020
1 parent 18612f2 commit 66ed68b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/GLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ LUA_FUNCTION(socketOpen)
}
//As soon as the socket starts connecting we want to keep a reference to the table so that it does not
//get garbage collected, so that the callbacks can be called.
LUA->Push(1);
socketTableReferences[socket] = LUA->ReferenceCreate();
if (socketTableReferences.find(socket) == socketTableReferences.end())
{
LUA->Push(1);
socketTableReferences[socket] = LUA->ReferenceCreate();
}
socket->open();
return 0;
}
Expand Down

0 comments on commit 66ed68b

Please sign in to comment.