r16527@catbus: nickm | 2007-11-07 12:27:59 -0500

Re-set all of the indices immediately after sorting old_routers.  Fixes a crash.


svn:r12413
This commit is contained in:
Nick Mathewson 2007-11-07 17:29:16 +00:00
parent bed01a9003
commit 9b2d86d83d

View File

@ -2987,12 +2987,16 @@ routerlist_remove_old_routers(void)
goto done; goto done;
smartlist_sort(routerlist->old_routers, _compare_old_routers_by_identity); smartlist_sort(routerlist->old_routers, _compare_old_routers_by_identity);
/* Fix indices. */
for (i = 0; i < smartlist_len(routerlist_old_routers); ++i) {
signed_descriptor_t *r = smartlist_get(routerlist->old_routers, i);
r->routerlist_index = i;
}
/* Iterate through the list from back to front, so when we remove descriptors /* Iterate through the list from back to front, so when we remove descriptors
* we don't mess up groups we haven't gotten to. */ * we don't mess up groups we haven't gotten to. */
for (i = smartlist_len(routerlist->old_routers)-1; i >= 0; --i) { for (i = smartlist_len(routerlist->old_routers)-1; i >= 0; --i) {
signed_descriptor_t *r = smartlist_get(routerlist->old_routers, i); signed_descriptor_t *r = smartlist_get(routerlist->old_routers, i);
r->routerlist_index = i;
if (!cur_id) { if (!cur_id) {
cur_id = r->identity_digest; cur_id = r->identity_digest;
hi = i; hi = i;