chiark
/
gitweb
/
~ian
/
chiark-tcl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use of int and overflow review
[chiark-tcl.git]
/
hbytes
/
hbytes.c
diff --git
a/hbytes/hbytes.c
b/hbytes/hbytes.c
index 5daecd1c5038437357fb896f1bd9d4e4b9044005..15980dcd6024e7518c8f60a7c1ba72bfb295f3d3 100644
(file)
--- a/
hbytes/hbytes.c
+++ b/
hbytes/hbytes.c
@@
-98,6
+98,8
@@
Byte *cht_hb_prepend(HBytes_Value *hb, int el) {
Byte *old_block, *new_block, *new_dstart;
cx= complex(hb);
Byte *old_block, *new_block, *new_dstart;
cx= complex(hb);
+
+ assert(el < INT_MAX/4 && cx->len < INT_MAX/2);
if (cx->prespace < el) {
new_prespace= el*2 + cx->len;
if (cx->prespace < el) {
new_prespace= el*2 + cx->len;
@@
-121,6
+123,7
@@
Byte *cht_hb_append(HBytes_Value *hb, int el) {
Byte *newpart, *new_block, *old_block;
cx= complex(hb);
Byte *newpart, *new_block, *old_block;
cx= complex(hb);
+ assert(el < INT_MAX/4 && cx->len < INT_MAX/4);
new_len= cx->len + el;
if (new_len > cx->avail) {
new_len= cx->len + el;
if (new_len > cx->avail) {