Skip to content

Commit c734324

Browse files
authored
[Foundation] Address a potential leak when writing a data to a URL and the file system representation fails (#14176)
1 parent 63f4fde commit c734324

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/SDK/Foundation/DataThunks.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ BOOL __NSDataWriteToURL(NSData *SWIFT_NS_RELEASES_ARGUMENT data, NSURL *SWIFT_NS
120120

121121
if (![path getFileSystemRepresentation:cpath maxLength:1024]) {
122122
if (errorPtr) *errorPtr = _NSErrorWithFilePath(NSFileWriteInvalidFileNameError, path);
123+
[data release];
124+
[url release];
123125
return NO;
124126
}
125127

0 commit comments

Comments
 (0)