aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-09-24 09:23:37 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-09-24 09:23:37 +0100
commitce5734e30235c3bac45a700ca7a245e4439a2efd (patch)
treee7f13ee258853b981583ed9ad319a90218478c30
parentb1e5a49ea2e23c31383f5c26e9ebcaba90bf8638 (diff)
downloadrspamd-ce5734e30235c3bac45a700ca7a245e4439a2efd.tar.gz
rspamd-ce5734e30235c3bac45a700ca7a245e4439a2efd.zip
[Minor] Another compatibility fix
-rw-r--r--src/lua/lua_rsa.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lua/lua_rsa.c b/src/lua/lua_rsa.c
index 78534c682..d797e3c19 100644
--- a/src/lua/lua_rsa.c
+++ b/src/lua/lua_rsa.c
@@ -261,6 +261,7 @@ lua_rsa_pubkey_gc(lua_State *L)
EVP_PKEY *pkey = lua_check_rsa_pubkey(L, 1);
if (pkey != NULL) {
+ /* It's actually EVP_PKEY_unref, thanks for that API */
EVP_PKEY_free(pkey);
}
@@ -522,6 +523,7 @@ lua_rsa_privkey_gc(lua_State *L)
EVP_PKEY *pkey = lua_check_rsa_privkey(L, 1);
if (pkey != NULL) {
+ /* It's actually EVP_PKEY_unref, thanks for that API */
EVP_PKEY_free(pkey);
}
@@ -806,12 +808,17 @@ lua_rsa_keypair(lua_State *L)
g_assert(EVP_PKEY_keygen(pctx, &pkey) == 1);
g_assert(pkey != NULL);
- priv_pkey = EVP_PKEY_dup(pkey);
+ /* Increase refcount and share */
+ g_assert(EVP_PKEY_up_ref(pkey) == 1);
+ priv_pkey = pkey;
+
ppkey = lua_newuserdata(L, sizeof(EVP_PKEY *));
rspamd_lua_setclass(L, rspamd_rsa_privkey_classname, -1);
*ppkey = priv_pkey;
- pub_pkey = EVP_PKEY_dup(pkey);
+ /* Increase refcount and share */
+ g_assert(EVP_PKEY_up_ref(pkey) == 1);
+ pub_pkey = pkey;
ppkey = lua_newuserdata(L, sizeof(EVP_PKEY *));
rspamd_lua_setclass(L, rspamd_rsa_pubkey_classname, -1);
*ppkey = pub_pkey;