summaryrefslogtreecommitdiffstats
path: root/buf.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 /buf.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 'buf.c')
-rw-r--r--buf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/buf.c b/buf.c
index 4fb25ad6..3cd050ef 100644
--- a/buf.c
+++ b/buf.c
@@ -160,7 +160,7 @@ static void buf_shrink(struct buf *b)
len = succ(len); /* avoid reallocing to zero length; i.e. freeing */
if (len != b->size) {
- b->data = chk_realloc(b->data, c_num(len));
+ b->data = chk_realloc(b->data, c_unum(len));
b->size = b->len;
}
}