Skip to content

Conversation

@egorzhdan
Copy link
Contributor

cxxString might get deallocated immediately after c_str() call, which would mean that the pointer passed to String(cString:) points to invalid memory.

We haven't actually seen this, but let's preemptively add an explicit withExtendedLifetime call to avoid running into this in the future.

Similar to #59152.

`cxxString` might get deallocated immediately after `c_str()` call, which would mean that the pointer passed to `String(cString:)` points to invalid memory.

We haven't actually seen this, but let's preemptively add an explicit `withExtendedLifetime` call to avoid running into this in the future.
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 7, 2022
@egorzhdan egorzhdan requested a review from zoecarver June 7, 2022 15:59
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit 59bb4cb into main Jun 7, 2022
@egorzhdan egorzhdan deleted the egorzhdan/cxx-overlay-dangling-ptr branch June 7, 2022 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ interop Feature: Interoperability with C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants