Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen: fix necessary clone when the closure param is string/array on autofree(fix #20498) #20557

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

shove70
Copy link
Contributor

@shove70 shove70 commented Jan 16, 2024

  1. Fixed Closure capturing an array results in use-after-free with autofree #20498
  2. Add tests.
fn foo() fn() {
    arr := [1, 2, 3]
    return fn [arr] () {
        println(arr)
    }
}

fn main() {
    print_arr := foo()
    print_arr()
}

v -autofree run a.v

[1, 2, 3]

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit d46274a into vlang:master Jan 16, 2024
54 checks passed
@shove70 shove70 deleted the patch-1 branch January 16, 2024 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Closure capturing an array results in use-after-free with autofree
2 participants