diff options
author | 2011-08-15 20:16:51 -0400 | |
---|---|---|
committer | 2011-08-15 20:16:51 -0400 | |
commit | eef6b96b495deb62f06c45d0689ce1deb8a4debb (patch) | |
tree | e15c6b0bea23c96e72b702309ac1eb5cfea8097c | |
parent | 9ed88138c7b842e854e322faa4716645011d2f68 (diff) | |
download | textadept-eef6b96b495deb62f06c45d0689ce1deb8a4debb.tar.gz textadept-eef6b96b495deb62f06c45d0689ce1deb8a4debb.zip |
Fixed memory access bug in gui.dialog(); src/textadept.c
-rw-r--r-- | src/textadept.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/textadept.c b/src/textadept.c index a9e7bda4..f590bc90 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -2008,7 +2008,7 @@ static int l_cf_gui_dialog(lua_State *lua) { int i, j, k, n = lua_gettop(lua) - 1, argc = n; for (i = 2; i < n + 2; i++) if (lua_type(lua, i) == LUA_TTABLE) argc += lua_objlen(lua, i) - 1; - const char **argv = malloc(argc * sizeof(const char *)); + const char **argv = malloc((argc + 1) * sizeof(const char *)); for (i = 0, j = 2; j < n + 2; j++) if (lua_type(lua, j) == LUA_TTABLE) { int len = lua_objlen(lua, j); @@ -2018,6 +2018,7 @@ static int l_cf_gui_dialog(lua_State *lua) { lua_pop(lua, 1); } } else argv[i++] = luaL_checkstring(lua, j); + argv[argc] = 0; char *out = gcocoadialog(type, argc, argv); lua_pushstring(lua, out); free(out); |