summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-08-13 22:26:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-08-13 22:26:35 -0700
commit1943a5b9233cbee3d0496e1763bc1e0b1f3f2ff3 (patch)
tree1462ce0bce79f59c355e42a38d8b6f3ed1d52a1a
parent334219659cd10540bee67458e96f3ea24023adac (diff)
downloadtxr-1943a5b9233cbee3d0496e1763bc1e0b1f3f2ff3.tar.gz
txr-1943a5b9233cbee3d0496e1763bc1e0b1f3f2ff3.tar.bz2
txr-1943a5b9233cbee3d0496e1763bc1e0b1f3f2ff3.zip
ffi: check for out-of-range wchar_t.
* ffi.c (ffi_wchar_get): Reject wchar_t values that are negative or beyond U+10FFFF; do not convert these to a character.
-rw-r--r--ffi.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ffi.c b/ffi.c
index 5a1513a2..bf59fb1d 100644
--- a/ffi.c
+++ b/ffi.c
@@ -1369,6 +1369,9 @@ static val ffi_wchar_get(struct txr_ffi_type *tft, mem_t *src, val self)
wchar_t c = *coerce(wchar_t *, src);
(void) tft;
(void) self;
+ if (c < 0 || c > 0x10FFFF)
+ uw_throwf(error_s, lit("~a: wchar_t value #x~X is out of character range"),
+ self, num(c), nao);
return chr(c);
align_sw_end;
}