JuliaStrings / utf8proc

a clean C library for processing UTF-8 Unicode data

Home Page:http://juliastrings.github.io/utf8proc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Commit 0643a6447995 makes utf8proc_grapheme_break() crash

bbolli opened this issue · comments

As explained in the comment 0643a64 line 299:

The way grapheme_break_extended() is coded after this commit makes it impossible to pass a NULL state pointer, which is what utf8proc_grapheme_break() unconditionally does.

Reproducer:

diff --git a/test/graphemetest.c b/test/graphemetest.c
index 95e7dc0..325e80d 100644
--- a/test/graphemetest.c
+++ b/test/graphemetest.c
@@ -61,7 +61,7 @@ void checkline(const char *_buf, bool verbose) {
     }

     if (si) { /* test manual calls to utf8proc_grapheme_break_stateful */
-        utf8proc_int32_t state = 0, prev_codepoint = 0;
+        utf8proc_int32_t prev_codepoint = 0;
         size_t i = 0;
         utf8proc_bool expectbreak = false;
         do {
@@ -72,7 +72,7 @@ void checkline(const char *_buf, bool verbose) {
                 expectbreak = true;
             else {
                 if (prev_codepoint != 0) {
-                    check(expectbreak == utf8proc_grapheme_break_stateful(prev_codepoint, codepoint, &state),
+                    check(expectbreak == utf8proc_grapheme_break(prev_codepoint, codepoint),
                           "grapheme mismatch: between 0x%04x and 0x%04x in \"%s\"", prev_codepoint, codepoint, (char*) src);
                 }
                 expectbreak = false;

Then make check crashes.