Skip to content

[Refactoring] Fix stack use after free in new async refactorings #35765

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

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/IDE/Refactoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5249,7 +5249,8 @@ bool RefactoringActionConvertCallToAsyncAlternative::performChange() {
assert(CE &&
"Should not run performChange when refactoring is not applicable");

AsyncConversionStringBuilder Builder(SM, DiagEngine, AsyncHandlerDesc());
AsyncHandlerDesc TempDesc;
AsyncConversionStringBuilder Builder(SM, DiagEngine, TempDesc);
Builder.convertNode(CE);

if (DiagEngine.hadAnyError())
Expand Down Expand Up @@ -5281,7 +5282,8 @@ bool RefactoringActionConvertToAsync::performChange() {
assert(FD &&
"Should not run performChange when refactoring is not applicable");

AsyncConversionStringBuilder Builder(SM, DiagEngine, AsyncHandlerDesc());
AsyncHandlerDesc TempDesc;
AsyncConversionStringBuilder Builder(SM, DiagEngine, TempDesc);
Builder.convertFunction(FD);

if (DiagEngine.hadAnyError())
Expand Down
2 changes: 0 additions & 2 deletions test/refactoring/ConvertAsync/basic.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rdar://problem/73984220
// XFAIL: asan
enum CustomError: Error {
case invalid
case insecure
Expand Down
2 changes: 0 additions & 2 deletions test/refactoring/ConvertAsync/convert_function.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rdar://problem/73984220
// XFAIL: asan
enum CustomError : Error {
case Bad
}
Expand Down
2 changes: 0 additions & 2 deletions test/refactoring/ConvertAsync/convert_params_multi.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rdar://problem/73984220
// XFAIL: asan
func manyWithError(_ completion: (String?, Int?, Error?) -> Void) { }

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):3 | %FileCheck -check-prefix=MANYBOUND %s
Expand Down
2 changes: 0 additions & 2 deletions test/refactoring/ConvertAsync/convert_params_single.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rdar://problem/73984220
// XFAIL: asan
func withError(_ completion: (String?, Error?) -> Void) { }
func test(_ str: String) -> Bool { return false }

Expand Down
2 changes: 0 additions & 2 deletions test/refactoring/ConvertAsync/convert_result.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rdar://problem/73984220
// XFAIL: asan
func simple(_ completion: (Result<String, Error>) -> Void) { }
func noError(_ completion: (Result<String, Never>) -> Void) { }
func test(_ str: String) -> Bool { return false }
Expand Down
2 changes: 0 additions & 2 deletions test/refactoring/ConvertAsync/errors.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// rdar://problem/73984220
// XFAIL: asan
func simple(completion: (String?, Error?) -> Void) { }

func mismatches() {
Expand Down