aboutsummaryrefslogtreecommitdiff
path: root/src/RangeSet.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-06-29 15:34:36 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-06-29 22:06:27 -0400
commit54454fd0102af8b25dbc85751d37fd265380d920 (patch)
treecdab71c06e0a8269fa3349c5b4b62be91d8cac4e /src/RangeSet.zig
parent8f2f0d8f0805f10523ced7e6a166ce81a097a54a (diff)
downloadzig-54454fd0102af8b25dbc85751d37fd265380d920.tar.gz
zig-54454fd0102af8b25dbc85751d37fd265380d920.zip
std.math.big.int: breaking API changes to prevent UAF
Many of the Managed methods accepted by-val parameters which could reference Limb slices that became invalid memory after any ensureCapacity calls. Now, Managed methods accept `*const Managed` parameters so that if the function allows aliasing and the ensure-capacity call resizes the Limb slice, it also affects the aliased parameters, avoiding use-after-free bugs. This is a breaking change that reduces the requirement for callsites to manually make the ensure-capacity changes prior to calling many of the Managed methods. Closes #11897
Diffstat (limited to 'src/RangeSet.zig')
-rw-r--r--src/RangeSet.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/RangeSet.zig b/src/RangeSet.zig
index 5b4c654529..84cae34365 100644
--- a/src/RangeSet.zig
+++ b/src/RangeSet.zig
@@ -85,7 +85,7 @@ pub fn spans(self: *RangeSet, first: Value, last: Value, ty: Type) !bool {
// prev.last + 1 == cur.first
try counter.copy(prev.last.toBigInt(&space, target));
- try counter.addScalar(counter.toConst(), 1);
+ try counter.addScalar(&counter, 1);
const cur_start_int = cur.first.toBigInt(&space, target);
if (!cur_start_int.eq(counter.toConst())) {