Skip to content

Commit 89ee154

Browse files
authored
cgen: fix auto-deref var in autofree string re-assignment (#26689)
1 parent 681b2f1 commit 89ee154

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

vlib/v/gen/c/assign.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
265265
g.write('${type_to_free} ${sref_name} = (') // TODO: we are copying the entire string here, optimize
266266
// we can't just do `.str` since we need the extra data from the string struct
267267
// doing `&string` is also not an option since the stack memory with the data will be overwritten
268+
if left0.is_auto_deref_var() {
269+
g.write('*')
270+
}
268271
g.expr(left0) // node.left[0])
269272
if first_left_type.has_flag(.shared_f) {
270273
g.write('->val')

0 commit comments

Comments
 (0)