diff options
author | Roger Dingledine <arma@torproject.org> | 2005-02-19 03:02:33 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-02-19 03:02:33 +0000 |
commit | 596d65ec3b3d54b9b7dc29fef54b5a193498e427 (patch) | |
tree | a2318a997087f79ecc80fac8bb91746f4b796d9e /src/common | |
parent | f30916830175a54bd8a3cf91e9ffc2402a064bd9 (diff) | |
download | tor-596d65ec3b3d54b9b7dc29fef54b5a193498e427.tar tor-596d65ec3b3d54b9b7dc29fef54b5a193498e427.tar.gz |
avoid case (not yet triggered) where smartlists could grow out
of control
svn:r3636
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/container.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/container.c b/src/common/container.c index 4dc0a7ad7..1824645ad 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -88,7 +88,9 @@ void smartlist_truncate(smartlist_t *sl, int len) /** Append element to the end of the list. */ void smartlist_add(smartlist_t *sl, void *element) { if (sl->num_used >= sl->capacity) { - sl->capacity *= 2; + int higher = sl->capacity * 2; + tor_assert(higher > sl->capacity); /* detect overflow */ + sl->capacity = higher; sl->list = tor_realloc(sl->list, sizeof(void*)*sl->capacity); } sl->list[sl->num_used++] = element; |