From 0049b5f6ed22a256033b51922e6416ddb291a48d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 4 May 2020 17:38:58 +0100 Subject: [PATCH] [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; } -- 2.39.5