commit 0bb92fb58983bce02bead90f98a835e883aa02c2
parent 0c191e78c88dcf53bc4c7133a625b6c9cb64c7ad
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 4 Nov 2022 09:40:23 +0100
slices: fix static_deletefrom length
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/slices/void.ha b/slices/void.ha
@@ -121,13 +121,14 @@ export fn static_deletefrom(
end: size,
) void = {
assert(start <= end);
+ assert(itemsz != 0);
if (start == end) {
return;
};
let sl = sl: *types::slice;
let data = sl.data: *[*]u8;
rt::memmove(&data[start * itemsz], &data[end * itemsz],
- (sl.length - start) * itemsz);
+ (sl.length - end) * itemsz);
sl.length -= end - start;
};