diff options
author | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2021-05-01 14:04:54 -0400 |
---|---|---|
committer | mitchell <70453897+orbitalquark@users.noreply.github.com> | 2021-05-01 14:04:54 -0400 |
commit | 3c2d3e5541a79728ccce40071608e8a2aea4e339 (patch) | |
tree | a2f56d169953ad896b622fc2bd21bbfc3c3098ce | |
parent | b95e2a2115b7e6bef0064aad821a749b031195d1 (diff) |
Do not clobber user's terminal on initialization error.
Also fix memory leak.
-rw-r--r-- | src/textadept.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/textadept.c b/src/textadept.c index 240580dc..1a19e0c1 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -2475,7 +2475,12 @@ int main(int argc, char **argv) { #endif setlocale(LC_COLLATE, "C"), setlocale(LC_NUMERIC, "C"); // for Lua - if (lua = luaL_newstate(), !init_lua(lua, argc, argv, false)) return 1; + if (lua = luaL_newstate(), !init_lua(lua, argc, argv, false)) { +#if CURSES + endwin(), termkey_destroy(ta_tk); +#endif + return (free(textadept_home), 1); + } initing = true, new_window(), run_file(lua, "init.lua", true), initing = false; emit(lua, "buffer_new", -1), emit(lua, "view_new", -1); // first ones lua_pushdoc(lua, SS(command_entry, SCI_GETDOCPOINTER, 0, 0)), lua_setglobal(lua, "buffer"); @@ -2575,8 +2580,7 @@ int main(int argc, char **argv) { refresh_all(); view = !command_entry_active ? focused_view : command_entry; } - endwin(); - termkey_destroy(ta_tk); + endwin(), termkey_destroy(ta_tk); #endif return (free(textadept_home), 0); |