mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
When there are no dir_server_ts to choose, don't crash
It's important not to call choose_array_element_by_weight and then
pass its return value unchecked to smartlist_get : it is allowed to
return -1.
Fixes bug 7756; bugfix on 4e3d07a6
(not in any released Tor)
This commit is contained in:
parent
7a99d26c79
commit
8b5787ec0d
@ -1270,7 +1270,7 @@ dirserver_choose_by_weight(const smartlist_t *servers, double authority_weight)
|
||||
scale_array_elements_to_u64(weights, n, NULL);
|
||||
i = choose_array_element_by_weight(weights, n);
|
||||
tor_free(weights);
|
||||
return smartlist_get(servers, i);
|
||||
return (i < 0) ? NULL : smartlist_get(servers, i);
|
||||
}
|
||||
|
||||
/** Choose randomly from among the dir_server_ts in sourcelist that
|
||||
|
Loading…
Reference in New Issue
Block a user