Skip to content

Commit

Permalink
Adding guard against temp directory create failure
Browse files Browse the repository at this point in the history
createDirectoryAtURL technically is not supposed to take a nil value - guard against this.
  • Loading branch information
colincornaby committed Feb 18, 2024
1 parent 21df00e commit 87434f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSPatcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,10 @@ static la_ssize_t copy_data(struct archive *ar, struct archive *aw)

NSError *error;
NSURL *tempDirectory = [NSFileManager.defaultManager URLForDirectory:NSItemReplacementDirectory inDomain:NSUserDomainMask appropriateForURL:[NSURL fileURLWithPath:NSFileManager.defaultManager.currentDirectoryPath] create:YES error:&error];
NSURL *outputURL = [tempDirectory URLByAppendingPathComponent:[NSString stringWithSTString:plManifest::PatcherExecutable().GetFileName()]];
[NSFileManager.defaultManager createDirectoryAtURL:outputURL withIntermediateDirectories:false attributes:nil error:&error];
if (tempDirectory) {
NSURL *outputURL = [tempDirectory URLByAppendingPathComponent:[NSString stringWithSTString:plManifest::PatcherExecutable().GetFileName()]];
[NSFileManager.defaultManager createDirectoryAtURL:outputURL withIntermediateDirectories:false attributes:nil error:&error];
}

if (error) {
// Not sure why things would go wrong, we should be able to
Expand Down

0 comments on commit 87434f2

Please sign in to comment.