Browse Source

Fix `lb_add_global_generated_with_name`

gingerBill 5 months ago
parent
commit
46c0910a77
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/llvm_backend_general.cpp

+ 3 - 2
src/llvm_backend_general.cpp

@@ -2790,8 +2790,9 @@ gb_internal lbAddr lb_add_global_generated_with_name(lbModule *m, Type *type, lb
 	GB_ASSERT(type != nullptr);
 	type = default_type(type);
 
-	isize max_len = 7+8+1;
-	u8 *str = cast(u8 *)gb_alloc_array(permanent_allocator(), u8, max_len);
+	u8 *str = cast(u8 *)gb_alloc_array(temporary_allocator(), u8, name.len);
+	memcpy(str, name.text, name.len);
+	str[name.len] = 0;
 
 	Scope *scope = nullptr;
 	Entity *e = alloc_entity_variable(scope, make_token_ident(name), type);