commit 0049b5f: [Minor] Allow to pre-allocate lua_text

Vsevolod Stakhov vsevolod at highsecure.ru
Mon May 4 17:14:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-05-04 17:38:58 +0100
URL: https://github.com/rspamd/rspamd/commit/0049b5f6ed22a256033b51922e6416ddb291a48d

[Minor] Allow to pre-allocate lua_text

---
 src/lua/lua_text.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lua/lua_text.c b/src/lua/lua_text.c
index e23eed8cb..2586b3302 100644
--- a/src/lua/lua_text.c
+++ b/src/lua/lua_text.c
@@ -198,7 +198,11 @@ lua_new_text (lua_State *L, const gchar *start, gsize len, gboolean own)
 
 		if (len > 0) {
 			storage = g_malloc (len);
-			memcpy (storage, start, len);
+
+			if (start != NULL) {
+				memcpy (storage, start, len);
+			}
+
 			t->start = storage;
 			t->flags = RSPAMD_TEXT_FLAG_OWN;
 		}


More information about the Commits mailing list