Skip to content

Commit 1c561c0

Browse files
authored
Merge pull request swiftlang#2861 from millenomi/url-empty-appendpathcomponent
URL.appendingPathComponent("") crashes
2 parents 70ac8ed + 7972e9b commit 1c561c0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CoreFoundation/URL.subproj/CFURL.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4805,7 +4805,7 @@ CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRe
48054805
newComp = CFURLCreateStringByAddingPercentEscapes(allocator, pathComponent, NULL, CFSTR(";?"), url->_encoding);
48064806
#pragma GCC diagnostic pop
48074807
}
4808-
if ( newComp ) {
4808+
if ( newComp && CFStringGetLength(newComp) > 0 ) {
48094809
pathRg = _rangeForComponent(url->_flags, url->_ranges, HAS_PATH);
48104810
if ( (!pathRg.length || CFStringGetCharacterAtIndex(url->_string, pathRg.location + pathRg.length - 1) != '/') && (CFStringGetCharacterAtIndex(newComp, 0) != '/') ) {
48114811
CFStringInsert(newString, pathRg.location + pathRg.length, CFSTR("/"));

0 commit comments

Comments
 (0)