aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-09-26 12:57:26 +0100
committergingerBill <bill@gingerbill.org>2023-09-26 12:57:26 +0100
commitd358ebd7e65a885e361af37de5143bfe91b222f4 (patch)
treeffa1367ffa601ffce3543c20672355f4f67b1821 /src/check_type.cpp
parent9711dd13816330ad9b7be81efbbfd1ffa3d999f4 (diff)
Potentially fix race condition #2463 #2814
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index cae3ba22e..dd9462ba5 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -613,6 +613,9 @@ gb_internal void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *
scope_reserve(ctx->scope, min_field_count);
+ rw_mutex_lock(&struct_type->Struct.fields_mutex);
+ defer (rw_mutex_unlock(&struct_type->Struct.fields_mutex));
+
if (st->is_raw_union && min_field_count > 1) {
struct_type->Struct.is_raw_union = true;
context = str_lit("struct #raw_union");