summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-17 17:55:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-17 17:55:13 -0700
commit3d95abc9d28983a21215c6156dd9d57374cfed53 (patch)
tree097c2f218a6ba9cc9796fa44287ca631ec458751 /lib.c
parenta6d77c200e36995d38bec27bed0976e1beda1b79 (diff)
downloadtxr-3d95abc9d28983a21215c6156dd9d57374cfed53.tar.gz
txr-3d95abc9d28983a21215c6156dd9d57374cfed53.tar.bz2
txr-3d95abc9d28983a21215c6156dd9d57374cfed53.zip
Fix overflow check using wrong variable.
* lib.c (chk_grow_vec): It is newelems which must be compared against the no_oflow value, not bytes.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index a7493ef0..7e1ad0e8 100644
--- a/lib.c
+++ b/lib.c
@@ -2023,7 +2023,7 @@ mem_t *chk_grow_vec(mem_t *old, size_t oldelems, size_t newelems,
internal_error("elsize == 0");
if (newelems <= oldelems ||
- ((bytes > no_oflow || elsize > no_oflow) && bytes / elsize != newelems))
+ ((newelems > no_oflow || elsize > no_oflow) && bytes / elsize != newelems))
uw_throw(error_s, lit("array size overflow"));
return chk_realloc(old, bytes);