Summary

UTF-decoding accesses uninitialized memory

Metadata

Description

The decoding of UTF-8 sequences in "utf8_decode" uses a branchless algorithm by Chris Wellon which potentially accesses bytes beyond the end of the input sequence. The code itself is correct since all sequences are terminated with a null byte, but the out-of-bounds access will result in valgrind messages and will trigger sanitizers.

The decoding routine should be replaced by one that doesn't perform out-of-bounds access but needs to be efficient, as this code is called on many string accesses. Note also that there is some special case code required to wrap invalid bytes into surrogate pair codes.