aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-24 18:42:59 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-24 18:42:59 +0200
commitd13b4a793d577be2364bcabb05bca1f19321b65a (patch)
tree950e679860a0e015f8d04b2d52e8919f5fd3ff86 /src
parent0570a4d050394f35e80a4e9a5b58a433f53e32b7 (diff)
downloadtdv-d13b4a793d577be2364bcabb05bca1f19321b65a.tar.gz
tdv-d13b4a793d577be2364bcabb05bca1f19321b65a.tar.xz
tdv-d13b4a793d577be2364bcabb05bca1f19321b65a.zip
Prevent undefined behaviour
Diffstat (limited to 'src')
-rw-r--r--src/stardict.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/stardict.c b/src/stardict.c
index cdd11a1..6775553 100644
--- a/src/stardict.c
+++ b/src/stardict.c
@@ -1014,6 +1014,10 @@ stardict_longest_common_collation_prefix (StardictDict *sd,
u_strFromUTF8 (NULL, 0, &uc2_len, s2, -1, &error);
error = U_ZERO_ERROR;
+ // Prevent undefined behaviour with VLAs.
+ if (!uc1_len || !uc2_len)
+ return 0;
+
UChar uc1[uc1_len];
UChar uc2[uc2_len];
u_strFromUTF8 (uc1, uc1_len, NULL, s1, -1, &error);