diff options
| author | Steven <burnett@posteo.de> | 2026-01-21 20:38:15 +0000 |
|---|---|---|
| committer | Steven <burnett@posteo.de> | 2026-01-21 20:38:15 +0000 |
| commit | 284d68b397abf68b664cbd9c8551aa8b62c5c1fc (patch) | |
| tree | 9b0b769ec3ed6265e4d4b43fb643f4d9b5885765 /std/stack.zc | |
| parent | d64e8001dc0003f55156292cb8194fddfd4bd446 (diff) | |
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.
Diffstat (limited to 'std/stack.zc')
| -rw-r--r-- | std/stack.zc | 2 |
1 files changed, 1 insertions, 1 deletions
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<T> { 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; } |
