From 284d68b397abf68b664cbd9c8551aa8b62c5c1fc Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 21 Jan 2026 20:38:15 +0000 Subject: fix: copy valid range when cloning stack When cloning a stack we are only interested in copying valid data from the original stack, not the unused/garbaged tail of it. --- std/stack.zc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'std/stack.zc') diff --git a/std/stack.zc b/std/stack.zc index 7df77f1..db02f2d 100644 --- a/std/stack.zc +++ b/std/stack.zc @@ -25,7 +25,7 @@ impl Stack { new_stack.len = self.len; new_stack.cap = self.cap; new_stack.data = malloc(sizeof(T) * new_stack.cap); - memcpy(new_stack.data, self.data, sizeof(T) * new_stack.cap); + memcpy(new_stack.data, self.data, sizeof(T) * new_stack.len); return new_stack; } -- cgit v1.2.3