diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2016-08-03 23:43:36 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2016-08-03 23:45:11 -0700 |
commit | 7812c553d33ce105afbc7696fb9e01ca92fba2ea (patch) | |
tree | 56ec485f4f77a805821d5a133aab8c9be1ba3d61 | |
parent | 010f4cf47a4a4a312b7fdcb05547d25d53b5d33b (diff) |
Fix segfault when encountering utf-8 characters
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/bonus.h | 2 | ||||
-rw-r--r-- | test/fzytest.c | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6625249..1cae016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.7 (unreleased) Bugfixes: + + - Fixed a segfault when encountering non-ascii characters - Fixed building against musl libc ## 0.6 (2016-07-26) diff --git a/src/bonus.h b/src/bonus.h index 43a42e2..89cafbe 100644 --- a/src/bonus.h +++ b/src/bonus.h @@ -103,6 +103,6 @@ const size_t bonus_index[256] = { ASSIGN_DIGIT(1) }; -#define COMPUTE_BONUS(last_ch, ch) (bonus_states[bonus_index[(size_t)(ch)]][(size_t)(last_ch)]) +#define COMPUTE_BONUS(last_ch, ch) (bonus_states[bonus_index[(unsigned char)(ch)]][(unsigned char)(last_ch)]) #endif diff --git a/test/fzytest.c b/test/fzytest.c index 0e0bad0..3786cd7 100644 --- a/test/fzytest.c +++ b/test/fzytest.c @@ -268,6 +268,17 @@ void test_choices_without_search() { choices_destroy(&choices); } +/* Regression test for segfault */ +void test_choices_unicode() { + choices_t choices; + choices_init(&choices); + + choices_add(&choices, "Edmund Husserl - Méditations cartésiennes - Introduction a la phénoménologie.pdf"); + choices_search(&choices, "e"); + + choices_destroy(&choices); +} + void summary() { printf("%i tests, %i assertions, %i failures\n", testsrun, assertionsrun, testsfailed); } @@ -298,6 +309,7 @@ int main(int argc, char *argv[]) { runtest(test_choices_1); runtest(test_choices_2); runtest(test_choices_without_search); + runtest(test_choices_unicode); summary(); |