diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index d385e37412..cebb692983 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -2221,11 +2221,20 @@ fn list_append<'a, 'ctx, 'env>( "add_list_lengths", ); + let elem_bytes = env + .ptr_int() + .const_int(elem_layout.stack_size(env.ptr_bytes) as u64, false); + let combined_bytes = builder.build_int_mul( + combined_list_len, + elem_bytes, + "add_list_lengths", + ); + let combined_list_ptr = env .builder .build_array_malloc( elem_type, - combined_list_len, + combined_bytes, "create_combined_list_ptr", ) .unwrap();