Skip to content

Commit eec8703

Browse files
committed
[stdlib] Keep a StringStorage alive.
Address a stdlib lifetime issue exposed by SSADestroyHoisting's more frequent (relative to DestroyHoisting's) expansion of store [assign]s.
1 parent 0656266 commit eec8703

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/core/StringGutsRangeReplaceable.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,13 @@ extension _StringGuts {
243243
internal mutating func appendInPlace(
244244
_ other: UnsafeBufferPointer<UInt8>, isASCII: Bool
245245
) {
246+
withExtendedLifetime(self._object) {
246247
self._object.nativeStorage.appendInPlace(other, isASCII: isASCII)
247248

248249
// We re-initialize from the modified storage to pick up new count, flags,
249250
// etc.
250251
self = _StringGuts(self._object.nativeStorage)
252+
}
251253
}
252254

253255
@inline(never) // slow-path

0 commit comments

Comments
 (0)