Skip to content

Commit 43eabf1

Browse files
committed
[Basic] Ensure empty NullTerminatedStringRef have valid pointer
NullterminatedStringRef is meant to be safe for reading 'data()' as a valid C-string. rdar://108215490
1 parent 1960739 commit 43eabf1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/swift/Basic/StringExtras.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class NullTerminatedStringRef {
490490

491491
/// Create a null-terminated string, copying \p Str into \p A .
492492
template <typename Allocator>
493-
NullTerminatedStringRef(StringRef Str, Allocator &A) : Ref() {
493+
NullTerminatedStringRef(StringRef Str, Allocator &A) : Ref("") {
494494
if (Str.empty())
495495
return;
496496

0 commit comments

Comments
 (0)