diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-13 17:46:08 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-13 17:46:08 -0800 |
commit | 12b2a44cf6413ef0c51c4e13af1c03369f9e803f (patch) | |
tree | 74126521afd4a7ab4320910f6886da6d5c156bc9 /src/lua.c | |
parent | 398112f756f2944df6165a9e9c81c9e62618f3bf (diff) | |
download | teliva-12b2a44cf6413ef0c51c4e13af1c03369f9e803f.tar.gz |
stop leaking memory
Diffstat (limited to 'src/lua.c')
-rw-r--r-- | src/lua.c | 5 |
1 files changed, 3 insertions, 2 deletions
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); |