]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Stop spurious clang shallow analysis null pointer errors
authorteor <teor2345@gmail.com>
Mon, 29 Sep 2014 00:08:37 +0000 (10:08 +1000)
committerNick Mathewson <nickm@torproject.org>
Mon, 29 Sep 2014 00:51:23 +0000 (20:51 -0400)
Avoid 4 null pointer errors under clang shallow analysis (the default when
building under Xcode) by using tor_assert() to prove that the pointers
aren't null. Resolves issue 13284 via minor code refactoring.

changes/issue13284-spurious-clang-shallow-analyze-errors [new file with mode: 0644]
src/or/dirserv.c
src/or/dirvote.c
src/or/routerlist.c

diff --git a/changes/issue13284-spurious-clang-shallow-analyze-errors b/changes/issue13284-spurious-clang-shallow-analyze-errors
new file mode 100644 (file)
index 0000000..c08fa1f
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes:
+    - Avoid 4 null pointer errors under clang shallow analysis by using
+      tor_assert() to prove that the pointers aren't null. Fixes bug 13284.
index 91314405df4ef6d028582a67c6f6fe83af7eb1c7..374cfa6f40a15b8b07fb05753177681ec97b1c34 100644 (file)
@@ -1395,6 +1395,8 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
       routerinfo_t *ri = node->ri;
       const char *id = node->identity;
       uint32_t bw_kb;
+      /* resolve spurious clang shallow analysis null pointer errors */
+      tor_assert(ri);
       node->is_exit = (!router_exit_policy_rejects_all(ri) &&
                        exit_policy_is_general_exit(ri->exit_policy));
       uptimes[n_active] = (uint32_t)real_uptime(ri, now);
index 9ad92ca116dbd7a762b9032dc3a069d56072771c..8a0fdf62fc23d38322913678a2f894b1663be313 100644 (file)
@@ -647,6 +647,8 @@ dirvote_compute_params(smartlist_t *votes, int method, int total_authorities)
       next_param = NULL;
     else
       next_param = smartlist_get(param_list, param_sl_idx+1);
+    /* resolve spurious clang shallow analysis null pointer errors */
+    tor_assert(param);
     if (!next_param || strncmp(next_param, param, cur_param_len)) {
       /* We've reached the end of a series. */
       /* Make sure enough authorities voted on this param, unless the
index 1faa05f06f4900c431c3da7aff50cc85a000929a..22489a44767631a40138e3e2be6af5d7da0007b8 100644 (file)
@@ -475,6 +475,8 @@ trusted_dirs_remove_old_certs(void)
         time_t cert_published;
         if (newest == cert)
           continue;
+        /* resolve spurious clang shallow analysis null pointer errors */
+        tor_assert(cert);
         expired = now > cert->expires;
         cert_published = cert->cache_info.published_on;
         /* Store expired certs for 48 hours after a newer arrives;