aboutsummaryrefslogtreecommitdiffstats
path: root/libcharconv_decode_utf8_.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcharconv_decode_utf8_.c')
-rw-r--r--libcharconv_decode_utf8_.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libcharconv_decode_utf8_.c b/libcharconv_decode_utf8_.c
index db66040..7b488e3 100644
--- a/libcharconv_decode_utf8_.c
+++ b/libcharconv_decode_utf8_.c
@@ -1,5 +1,7 @@
/* See LICENSE file for copyright and license details. */
#include "lib-common.h"
+#include <stdlib.h>
+#include <stdio.h>
size_t
@@ -37,6 +39,8 @@ libcharconv_decode_utf8_(const char *s, size_t slen, uint_least32_t *cp)
return n;
for (i = 1u; i < n; i++) {
+ if ((s[i] & 0xC0) != 0x80)
+ return 0u;
*cp <<= 6;
*cp |= (uint_least32_t)s[i] & 0x3Fu;
}