浏览代码

Work around the static analyzer false report.

Thomas Van Lenten 7 年之前
父节点
当前提交
81aeed082e
共有 1 个文件被更改,包括 6 次插入0 次删除
  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)) {
     if (!atomic_compare_exchange_strong(&self->readOnlySemaphore_, &expected, worker)) {
       dispatch_release(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
 #pragma clang diagnostic pop