aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-12-22 19:25:08 +1300
committerTom Ryder <tom@sanctum.geek.nz>2019-12-22 19:25:08 +1300
commitf602816cdd6278b098011dcb136818ba99ecfec9 (patch)
tree947f0d7afcb8f852533b1926792dc7cddfcaf051
parentMerge branch 'release/v1.2.0' (diff)
parentBump VERSION (diff)
downloadwtf8-f602816cdd6278b098011dcb136818ba99ecfec9.tar.gz
wtf8-f602816cdd6278b098011dcb136818ba99ecfec9.zip
Merge branch 'hotfix/v1.2.1'v1.2.1
* hotfix/v1.2.1: Bounds checking on character byte walk
-rw-r--r--VERSION2
-rw-r--r--wtf8.c4
-rw-r--r--wtf8.h1
3 files changed, 4 insertions, 3 deletions
diff --git a/VERSION b/VERSION
index 26aaba0..6085e94 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.0
+1.2.1
diff --git a/wtf8.c b/wtf8.c
index e277d1a..714a7cc 100644
--- a/wtf8.c
+++ b/wtf8.c
@@ -35,7 +35,7 @@ void print_characters(char *s) {
/*
* We need a short counter to find how long each character is
*/
- int c;
+ unsigned char c;
/*
* Iterate through the string
@@ -46,7 +46,7 @@ void print_characters(char *s) {
* Print blanks and increment a counter until we find how long this
* character is
*/
- for (c = 1; is_utf8_cont(s[c]); c++)
+ for (c = 1; is_utf8_cont(s[c]) && c <= UCHAR_MAX; c++)
printf(" ");
/*
diff --git a/wtf8.h b/wtf8.h
index 5a80f30..a635e1e 100644
--- a/wtf8.h
+++ b/wtf8.h
@@ -1,3 +1,4 @@
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>