From 5b312aa63e8a6a1350d7c5081cf7a532592ee3f3 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 6 Nov 2021 18:49:45 -0700 Subject: [PATCH] Fix null deference analyzer warnings (#2011) --- .github/workflows/ci.yml | 13 +++++++++---- Sparkle/SPUUpdater.m | 8 ++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a7b24257..d6316b47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,22 +60,27 @@ jobs: - name: Find Analyzed Warnings if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' }} + id: findwarnings env: DEVELOPER_DIR: ${{ matrix.xcode-path }} run: | - grep -q "warning:" anaylze_output.txt + if grep -q "warning:" anaylze_output.txt; then + echo '::set-output name=analyzestatus::0' + else + echo '::set-output name=analyzestatus::1' + fi - name: Extract Analyzed Warnings - if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' }} + if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' && steps.findwarnings.outputs.analyzestatus == '0' }} id: warnings run: | echo ::set-output name=content::$(cat anaylze_output.txt) - name: Post Analyzed Warnings - if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' }} + if: ${{ success() && matrix.run-analyzer && github.event_name == 'pull_request' && steps.findwarnings.outputs.analyzestatus == '0' }} uses: mshick/add-pr-comment@v1 with: - allow-repeats: true + allow-repeats: false repo-token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }} repo-token-user-login: 'Sparkle-Bot' message: "``` ${{ steps.warnings.outputs.content }} ```" diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index 1d4ce71f..4c78fd83 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -225,7 +225,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification NSURL *xpcServiceBundleURL = [[self.sparkleBundle.bundleURL URLByAppendingPathComponent:@"XPCServices"] URLByAppendingPathComponent:xpcServiceBundleName]; if (![xpcServiceBundleURL checkResourceIsReachableAndReturnError:NULL]) { - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"XPC Service is enabled (%@) but does not exist: %@", xpcServiceEnabledKey, xpcServiceBundleURL.path] }]; + if (error != NULL) { + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"XPC Service is enabled (%@) but does not exist: %@", xpcServiceEnabledKey, xpcServiceBundleURL.path] }]; + } return NO; } @@ -235,7 +237,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification NSURL *mainBundleXPCServiceURL = [[[mainBundle.bundleURL URLByAppendingPathComponent:@"Contents"] URLByAppendingPathComponent:@"XPCServices"] URLByAppendingPathComponent:xpcServiceBundleName]; if ([mainBundleXPCServiceURL checkResourceIsReachableAndReturnError:NULL]) { - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"XPC Service (%@) must be in the Sparkle framework, not in the application bundle (%@). Please visit https://sparkle-project.org/documentation/sandboxing/ for up to date Sandboxing instructions.", xpcServiceBundleName, mainBundleXPCServiceURL.path] }]; + if (error != NULL) { + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInvalidUpdaterError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"XPC Service (%@) must be in the Sparkle framework, not in the application bundle (%@). Please visit https://sparkle-project.org/documentation/sandboxing/ for up to date Sandboxing instructions.", xpcServiceBundleName, mainBundleXPCServiceURL.path] }]; + } return NO; }