diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-12-29 04:50:32 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-12-29 15:28:40 -0500 |
| commit | ec60156f187a9baa02e0ac7e15ee7a864f098dcf (patch) | |
| tree | 16944042364dc40cadcb204c32909b5d7fa8fa85 /src | |
| parent | 271452d225803770d29af1c9401fc610254d23c2 (diff) | |
| download | zig-ec60156f187a9baa02e0ac7e15ee7a864f098dcf.tar.gz zig-ec60156f187a9baa02e0ac7e15ee7a864f098dcf.zip | |
InternPool: fix leak when the last namespace bucket is full
Diffstat (limited to 'src')
| -rw-r--r-- | src/InternPool.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index 681d2b4957..fdeddcfa2f 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -2046,7 +2046,7 @@ pub const Key = union(enum) { }, /// This type originates from a reification via `@Type`, or from an anonymous initialization. /// It is hashed based on its ZIR instruction index and fields, attributes, etc. - /// To avoid making this key overly complex, the type-specific data is hased by Sema. + /// To avoid making this key overly complex, the type-specific data is hashed by Sema. reified: struct { /// A `reify`, `struct_init`, `struct_init_ref`, or `struct_init_anon` instruction. zir_index: TrackedInst.Index, @@ -11287,7 +11287,8 @@ pub fn createNamespace( return reused_namespace_index; } const namespaces = local.getMutableNamespaces(gpa); - if (local.mutate.namespaces.last_bucket_len == 0) { + const last_bucket_len = local.mutate.namespaces.last_bucket_len & Local.namespaces_bucket_mask; + if (last_bucket_len == 0) { try namespaces.ensureUnusedCapacity(1); var arena = namespaces.arena.promote(namespaces.gpa); defer namespaces.arena.* = arena.state; @@ -11298,10 +11299,9 @@ pub fn createNamespace( const unwrapped_namespace_index: NamespaceIndex.Unwrapped = .{ .tid = tid, .bucket_index = namespaces.mutate.len - 1, - .index = local.mutate.namespaces.last_bucket_len, + .index = last_bucket_len, }; - local.mutate.namespaces.last_bucket_len = - (unwrapped_namespace_index.index + 1) & Local.namespaces_bucket_mask; + local.mutate.namespaces.last_bucket_len = last_bucket_len + 1; const namespace_index = unwrapped_namespace_index.wrap(ip); ip.namespacePtr(namespace_index).* = initialization; return namespace_index; |
