summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2016-07-03 22:51:35 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2016-07-12 00:42:48 -0700
commitda86472d7399ff110baf819faad927703173b6d2 (patch)
treee12ff87c2a6398b167ec5f541c974f41e0cc2698
parentcf9bba88b3a384e49a91c52968db57c60dc454eb (diff)
Fix segfault when autocompleting on no matches
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/tty_interface.c5
2 files changed, 5 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 085f002..ca93562 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ Performance:
Bugfixes:
- Fixed command line parsing on ARM
+ - Fix error when autocompleting and there are no matches
## 0.5 (2016-06-11)
diff --git a/src/tty_interface.c b/src/tty_interface.c
index 0f33305..9ca93c1 100644
--- a/src/tty_interface.c
+++ b/src/tty_interface.c
@@ -166,7 +166,10 @@ static void action_pagedown(tty_interface_t *state) {
static void action_autocomplete(tty_interface_t *state) {
update_state(state);
- strncpy(state->search, choices_get(state->choices, state->choices->selection), SEARCH_SIZE_MAX);
+ const char *current_selection = choices_get(state->choices, state->choices->selection);
+ if (current_selection) {
+ strncpy(state->search, choices_get(state->choices, state->choices->selection), SEARCH_SIZE_MAX);
+ }
}
static void action_exit(tty_interface_t *state) {