Skip to content

Commit 8914430

Browse files
committed
Keep the __StringStorage alive while we're using its buffer
1 parent 4209361 commit 8914430

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

stdlib/public/core/StringCreate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ extension String {
120120
)
121121
return result.asString
122122
case .error(let initialRange):
123+
defer { _fixLifetime(result) }
123124
//This could be optimized to use excess tail capacity
124125
return repairUTF8(result.codeUnits, firstKnownBrokenRange: initialRange)
125126
}

0 commit comments

Comments
 (0)