Package: termit Version: 3.1-1 Severity: normal
There is a bug in termit_for_each_row_execute() (used to implement the forEachRow() and forEachVisibleRow() termit lua API functions) in src/termit_core_api.c. The code seems to assume that vte_terminal_get_text_range() will return strings ending in '\n', and tries to remove these by setting str[strlen(str) - 1] = '\0'. However, this assumption is false. Thus the last char of each non-empty line passed to the user's callback function is truncated. Moreover, on empty lines (where strlen(str)==0), str[-1] will be written to. In the line above there is another, more harmless bug: &lua_callback is mistakenly passed as the user_data argument of vte_terminal_get_text_range(); this makes no sense as the user_data would be passed to the optional is_selected callback function (the preceeding arg to vte_terminal_get_text_range()), which termit doesn't use (it passes NULL instead). See the VTE docs: https://developer.gnome.org/vte/unstable/VteTerminal.html#vte-terminal-get-text-range The attached patch addresses both issues. --- src/termit_core_api.c.orig +++ src/termit_core_api.c @@ -281,8 +281,7 @@ { glong i = row_start; for (; i < row_end; ++i) { - char* str = vte_terminal_get_text_range(VTE_TERMINAL(pTab->vte), i, 0, i, 500, NULL, &lua_callback, NULL); - str[strlen(str) - 1] = '\0'; + char* str = vte_terminal_get_text_range(VTE_TERMINAL(pTab->vte), i, 0, i, 500, NULL, NULL, NULL); termit_lua_dofunction2(lua_callback, str); free(str); }

