Browse Source

Work around the static analyzer false report.

Thomas Van Lenten 7 years ago
parent
commit
81aeed082e
1 changed files with 6 additions and 0 deletions
  1. 6 0
      objectivec/GPBMessage.m

+ 6 - 0
objectivec/GPBMessage.m

@@ -753,6 +753,12 @@ void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
     if (!atomic_compare_exchange_strong(&self->readOnlySemaphore_, &expected, worker)) {
       dispatch_release(worker);
     }
+#if defined(__clang_analyzer__)
+    // The Xcode 9.2 (and 9.3 beta) static analyzer thinks worker is leaked
+    // (doesn't seem to know about atomic_compare_exchange_strong); so just
+    // for the analyzer, let it think worker is also released in this case.
+    else { dispatch_release(worker); }
+#endif
   }
 
 #pragma clang diagnostic pop