Eli Zaretskii schrieb am Sa., 23. Dez. 2017 um 17:37 Uhr: > > From: Philipp Stephani > > Date: Sat, 23 Dec 2017 16:20:04 +0000 > > Cc: phst@google.com, emacs-devel@gnu.org > > > > static void > > json_check_utf8 (Lisp_Object string) > > { > > eassert (!STRING_MULTIBYTE (string)); > > struct coding_system coding; > > setup_coding_system (Qutf_8_unix, &coding); > > /* We initialize only the fields that check_utf_8 accesses. */ > > coding.src_pos = 0; > > coding.src_pos_byte = 0; > > coding.src_chars = SCHARS (string); > > coding.src_bytes = SBYTES (string); > > coding.src_object = string; > > coding.eol_seen = EOL_SEEN_NONE; > > CHECK_TYPE (check_utf_8 (&coding) >= 0, Qutf_8_string_p, string); > > } > > > > This apparently fails to detect the unibyte string "u\xFFv" as invalid > UTF-8. > > How can that be? 0xFF shouldn't pass any of the > UTF_8_n_OCTET_LEADING_P tests, so it should end up in 'else', where > the function returns -1. Right? > > You also need to initialize the head_ascii member, I think. Maybe its > being uninitialized explains the failure. > > Yes, that's it, thanks.