aboutsummaryrefslogtreecommitdiff
path: root/lib/charset.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-08-08 21:38:05 -0400
committerTom Rini <trini@konsulko.com>2023-08-08 21:38:05 -0400
commit1e1437d9f8b5be362afdd0212dbae6c41f53f3d8 (patch)
tree7c22536424032112c0c5e3ddce45f0333478f355 /lib/charset.c
parenta169438411f9277cc689c14078151aa1d1caae3c (diff)
parent70fdcc704a978acb4de5e891469825596c0d292e (diff)
Merge branch '2023-08-08-assorted-code-corrections' into next
- A number of code corrections caught by Smatch and a few others as well.
Diffstat (limited to 'lib/charset.c')
-rw-r--r--lib/charset.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/charset.c b/lib/charset.c
index b1842755eb..5e4c4f948a 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -444,14 +444,14 @@ u16 *u16_strdup(const void *src)
size_t u16_strlcat(u16 *dest, const u16 *src, size_t count)
{
- size_t destlen = u16_strlen(dest);
+ size_t destlen = u16_strnlen(dest, count);
size_t srclen = u16_strlen(src);
- size_t ret = destlen + srclen + 1;
+ size_t ret = destlen + srclen;
if (destlen >= count)
return ret;
- if (ret > count)
- srclen -= ret - count;
+ if (ret >= count)
+ srclen -= (ret - count + 1);
memcpy(&dest[destlen], src, 2 * srclen);
dest[destlen + srclen] = 0x0000;