Skip to content

Commit 7972e9b

Browse files
committed
URL.appendingPathComponent("") crashes
Do not attempt to read characters from this string if it's empty. 66580574
1 parent ca6cda5 commit 7972e9b

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)