From 12b2a44cf6413ef0c51c4e13af1c03369f9e803f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 13 Nov 2021 17:46:08 -0800 Subject: stop leaking memory --- src/lua.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lua.c') diff --git a/src/lua.c b/src/lua.c index 8796ca7..f226828 100644 --- a/src/lua.c +++ b/src/lua.c @@ -304,9 +304,10 @@ static int handle_image (lua_State *L, char **argv, int n) { } -const char *Current_definition = NULL; +#define CURRENT_DEFINITION_LEN 256 +char Current_definition[CURRENT_DEFINITION_LEN+1] = {0}; void save_to_current_definition_and_editor_buffer (lua_State *L, const char *definition) { - Current_definition = strdup(definition); + strncpy(Current_definition, definition, CURRENT_DEFINITION_LEN); lua_getglobal(L, "teliva_program"); lua_getfield(L, -1, Current_definition); const char *contents = lua_tostring(L, -1); -- cgit 1.4.1-2-gfad0