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
commite152f22be647d5f6b4c89cd4cfd639f0482ffbbe (patch)
tree1462ce0bce79f59c355e42a38d8b6f3ed1d52a1a
parent83ae6fd08039a96d0b0b897d8a0bc55af6854853 (diff)
downloadtxr-e152f22be647d5f6b4c89cd4cfd639f0482ffbbe.tar.gz
txr-e152f22be647d5f6b4c89cd4cfd639f0482ffbbe.tar.bz2
txr-e152f22be647d5f6b4c89cd4cfd639f0482ffbbe.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;
}