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; }