From d358ebd7e65a885e361af37de5143bfe91b222f4 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 26 Sep 2023 12:57:26 +0100 Subject: Potentially fix race condition #2463 #2814 --- src/check_type.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/check_type.cpp') 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"); -- cgit v1.2.3