diff options
Diffstat (limited to 'src/lua/lua_cryptobox.c')
-rw-r--r-- | src/lua/lua_cryptobox.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c index 9cea18311..f16fd8b67 100644 --- a/src/lua/lua_cryptobox.c +++ b/src/lua/lua_cryptobox.c @@ -2019,6 +2019,10 @@ lua_cryptobox_encrypt_memory (lua_State *L) gint ret = luaL_error (L, "cannot encrypt data: %s", err->message); g_error_free (err); + if (owned_pk) { + rspamd_pubkey_unref (pk); + } + return ret; } } @@ -2027,6 +2031,10 @@ lua_cryptobox_encrypt_memory (lua_State *L) gint ret = luaL_error (L, "cannot encrypt data: %s", err->message); g_error_free (err); + if (owned_pk) { + rspamd_pubkey_unref (pk); + } + return ret; } } @@ -2065,7 +2073,7 @@ lua_cryptobox_encrypt_file (lua_State *L) struct rspamd_cryptobox_keypair *kp = NULL; struct rspamd_cryptobox_pubkey *pk = NULL; const gchar *filename; - gchar *data; + gchar *data = NULL; guchar *out = NULL; struct rspamd_lua_text *res; gsize len = 0, outlen = 0; @@ -2104,6 +2112,9 @@ lua_cryptobox_encrypt_file (lua_State *L) err->message); g_error_free (err); munmap (data, len); + if (own_pk) { + rspamd_pubkey_unref (pk); + } return ret; } @@ -2115,6 +2126,10 @@ lua_cryptobox_encrypt_file (lua_State *L) g_error_free (err); munmap (data, len); + if (own_pk) { + rspamd_pubkey_unref (pk); + } + return ret; } } @@ -2132,6 +2147,9 @@ lua_cryptobox_encrypt_file (lua_State *L) return 1; err: + if (data) { + munmap (data, len); + } if (own_pk) { rspamd_pubkey_unref (pk); } |