summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-04-25 08:17:22 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-04-25 08:17:22 -0700
commit0b52768a15706b53e38890e1dc1ebc7f92e00166 (patch)
tree6306b6ddc21336d37413de4efd59756fdaec9197 /lib.c
parentfe6db6bcc360dded3383f06a47275610371be874 (diff)
downloadtxr-0b52768a15706b53e38890e1dc1ebc7f92e00166.tar.gz
txr-0b52768a15706b53e38890e1dc1ebc7f92e00166.tar.bz2
txr-0b52768a15706b53e38890e1dc1ebc7f92e00166.zip
lib/buf: use unsigned integers around allocations.
* buf.c (buf_shrink): Convert len to alloc size using c_unum, which will reject negative values that will implicitly convert to a wrong/huge size. * lib.c (upcase_str, downcase_str): Similar reasoning. (sub_vec): nelem is a size_t, so use unum on it, rather than num.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index 1ad10b78..e1ffbf66 100644
--- a/lib.c
+++ b/lib.c
@@ -3574,7 +3574,7 @@ val copy_str(val str)
val upcase_str(val str)
{
val len = length_str(str);
- wchar_t *dst = chk_wmalloc(c_num(len) + 1);
+ wchar_t *dst = chk_wmalloc(c_unum(len) + 1);
const wchar_t *src = c_str(str);
val out = string_own(dst);
@@ -3587,7 +3587,7 @@ val upcase_str(val str)
val downcase_str(val str)
{
val len = length_str(str);
- wchar_t *dst = chk_wmalloc(c_num(len) + 1);
+ wchar_t *dst = chk_wmalloc(c_unum(len) + 1);
const wchar_t *src = c_str(str);
val out = string_own(dst);
@@ -7553,7 +7553,7 @@ val sub_vec(val vec_in, val from, val to)
#endif
v += 2;
vec->v.vec = v;
- v[vec_length] = v[vec_alloc] = num(nelem);
+ v[vec_length] = v[vec_alloc] = unum(nelem);
memcpy(vec->v.vec, vec_in->v.vec + cfrom, nelem * sizeof *vec->v.vec);
return vec;
}