commit 7c0ded8: [Fix] Sigh, another email to string fix
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Oct 22 14:56:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-22 15:52:27 +0100
URL: https://github.com/rspamd/rspamd/commit/7c0ded82ed4f4d179226e16912b8529d82f5d9a8 (HEAD -> master)
[Fix] Sigh, another email to string fix
---
src/lua/lua_url.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 57be4c009..4b923d3ef 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -302,21 +302,15 @@ lua_url_tostring (lua_State *L)
if (url != NULL && url->url != NULL) {
if (url->url->protocol == PROTOCOL_MAILTO) {
- if (url->url->userlen + 1 + url->url->hostlen == url->url->urllen) {
- lua_pushlstring (L, url->url->string, url->url->urllen);
- }
- else {
- /* TODO: not efficient */
- gchar *tmp = g_malloc (url->url->userlen + 1 +
- url->url->hostlen);
- memcpy (tmp, url->url->user, url->url->userlen);
- tmp[url->url->userlen] = '@';
- memcpy (tmp + url->url->userlen + 1, url->url->host,
- url->url->hostlen);
-
- lua_pushlstring (L, tmp, url->url->userlen + 1 + url->url->hostlen);
- g_free (tmp);
- }
+ gchar *tmp = g_malloc (url->url->userlen + 1 +
+ url->url->hostlen);
+ memcpy (tmp, url->url->user, url->url->userlen);
+ tmp[url->url->userlen] = '@';
+ memcpy (tmp + url->url->userlen + 1, url->url->host,
+ url->url->hostlen);
+
+ lua_pushlstring (L, tmp, url->url->userlen + 1 + url->url->hostlen);
+ g_free (tmp);
}
else {
lua_pushlstring (L, url->url->string, url->url->urllen);
More information about the Commits
mailing list