Fix potential null pointer deref during dirvote

Found by using clang's analyzer.
This commit is contained in:
Sebastian Hahn 2011-04-26 04:38:55 +02:00 committed by Nick Mathewson
parent 1827e60976
commit 1c668540fe
2 changed files with 7 additions and 3 deletions

View File

@ -0,0 +1,4 @@
o Minor bugfixes:
- Fix a potential null-pointer dereference while computing a consensus.
Bugfix on tor-0.2.0.3-alpha, found with the help of clang's analyzer.

View File

@ -444,9 +444,9 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
if (cur && !compare_vote_rs(cur, rs)) {
++cur_n;
} else {
if (cur_n > most_n ||
(cur && cur_n == most_n &&
cur->status.published_on > most_published)) {
if (cur && (cur_n > most_n ||
(cur_n == most_n &&
cur->status.published_on > most_published))) {
most = cur;
most_n = cur_n;
most_published = cur->status.published_on;