aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTaylor Yu <catalyst@torproject.org>2018-03-26 17:51:50 -0500
committerTaylor Yu <catalyst@torproject.org>2018-03-27 15:29:00 -0500
commit4bb7d9fd1241a3c263636efa03ee8c62ab744515 (patch)
treede2b258b7bd9a6f830d0bd918613f671b39add3e /src
parent9f93bcd16d70b540c518acee56a440be12072ef7 (diff)
downloadtor-4bb7d9fd1241a3c263636efa03ee8c62ab744515.tar.gz
tor-4bb7d9fd1241a3c263636efa03ee8c62ab744515.zip
Fix CID 1430932
Coverity found a null pointer reference in nodelist_add_microdesc(). This is almost certainly impossible assuming that the routerstatus_t returned by router_get_consensus_status_by_descriptor_digest() always corresponds to an entry in the nodelist. Fixes bug 25629.
Diffstat (limited to 'src')
-rw-r--r--src/or/nodelist.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 5a02648c5c..26f990b08c 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -263,13 +263,12 @@ nodelist_add_microdesc(microdesc_t *md)
if (rs == NULL)
return NULL;
node = node_get_mutable_by_id(rs->identity_digest);
- if (node) {
- if (node->md)
- node->md->held_by_nodes--;
- node->md = md;
- md->held_by_nodes++;
- }
-
+ if (node == NULL)
+ return NULL;
+ if (node->md)
+ node->md->held_by_nodes--;
+ node->md = md;
+ md->held_by_nodes++;
node_add_to_address_set(node);
return node;