diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-04-25 08:17:22 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-04-25 08:17:22 -0700 |
commit | 0b52768a15706b53e38890e1dc1ebc7f92e00166 (patch) | |
tree | 6306b6ddc21336d37413de4efd59756fdaec9197 /buf.c | |
parent | fe6db6bcc360dded3383f06a47275610371be874 (diff) | |
download | txr-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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; } } |