(tree_do_search): fix possible off-by-one (PVS-Studio:V557)

Signed-off-by: Andrew V. Samoilov <a.samoilov@gmail.com>
This commit is contained in:
Andrew V. Samoilov 2019-01-23 09:54:12 +02:00 committed by Andrew Borodin
parent 05ea41cdb5
commit ceefccbd5a

View File

@ -654,7 +654,7 @@ tree_do_search (WTree * tree, int key)
l = strlen (tree->search_buffer);
if ((l != 0) && (key == KEY_BACKSPACE))
tree->search_buffer[--l] = '\0';
else if (key && l < sizeof (tree->search_buffer))
else if (key && l < sizeof (tree->search_buffer) - 1)
{
tree->search_buffer[l] = key;
tree->search_buffer[++l] = '\0';