aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/lists.c8
-rw-r--r--src/stdlib/tables.c2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/stdlib/lists.c b/src/stdlib/lists.c
index af0d1e0a..f5be09e9 100644
--- a/src/stdlib/lists.c
+++ b/src/stdlib/lists.c
@@ -76,11 +76,15 @@ public void List$insert(List_t *list, const void *item, Int_t int_index, int64_t
list->data_refcount = 0;
list->stride = padded_item_size;
} else {
- if (index != list->length+1)
+ if (index != list->length+1) {
+ assert(list->length >= index);
+ size_t size = (size_t)((list->length - index + 1)*padded_item_size);
+ assert(size < SIZE_MAX);
memmove(
list->data + index*padded_item_size,
list->data + (index-1)*padded_item_size,
- (size_t)((list->length - index + 1)*padded_item_size));
+ size);
+ }
}
assert(list->free > 0);
--list->free;
diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c
index c01ac25e..c26fd798 100644
--- a/src/stdlib/tables.c
+++ b/src/stdlib/tables.c
@@ -556,7 +556,7 @@ PUREFUNC public uint64_t Table$hash(const void *obj, const TypeInfo_t *type)
keys_hash ^= generic_hash(t->entries.data + i*t->entries.stride, table.key);
}
- struct {
+ volatile struct {
int64_t length;
uint64_t keys_hash, values_hash;
Table_t *fallback;