summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/bonus.h2
-rw-r--r--test/fzytest.c12
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();