From 21e4cc42cc830f9a7d46492e6b98bc6d829ac749 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 7 Oct 2015 18:44:14 -0400 Subject: [PATCH] Fix segfault when patch path has insufficient write permissions --- Sparkle/SUBinaryDeltaCreate.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index db790642..98a6f08b 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -439,6 +439,16 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF NSString *temporaryFile = temporaryPatchFile(patchFile); xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE); + if (!x) { + if (verbose) { + fprintf(stderr, "\n"); + } + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write to %@", temporaryFile] }]; + } + return NO; + } + xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2"); xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY);