# HG changeset patch # User Matthew Wild # Date 1289048649 0 # Node ID 4bc25168aa1c8de91da15fa1da4d2f472ca512eb # Parent bbf12f9be71c7d0257632143d5e22eb2ce0282df x509: Add __gc to free X509 object on destruction diff -r bbf12f9be71c -r 4bc25168aa1c src/x509.c --- a/src/x509.c Sat Nov 06 01:10:01 2010 +0000 +++ b/src/x509.c Sat Nov 06 13:04:09 2010 +0000 @@ -258,6 +258,12 @@ return 1; } +int meth_destroy(lua_State* L) +{ + X509_free(luasec_to_x509(L, 1)); + return 0; +} + /** * Certificate metamethods */ @@ -278,7 +284,8 @@ lua_newtable(L); luaL_register(L, NULL, meta); lua_setfield(L, -2, "__index"); - + lua_pushcfunction(L, meth_destroy); + lua_setfield(L, -2, "__gc"); lua_newtable(L); return 1; }