summaryrefslogtreecommitdiff
path: root/src/common/container.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-02-21 03:42:56 +0000
committerNick Mathewson <nickm@torproject.org>2008-02-21 03:42:56 +0000
commit47e6247673e4d47f30467e78897c5364320e860b (patch)
tree8c37b660b7f0ddc03771a3a41121298ae3ee7ffb /src/common/container.c
parent1df0647c668645268b1b9c0246b91cad709e3708 (diff)
downloadtor-47e6247673e4d47f30467e78897c5364320e860b.tar.gz
tor-47e6247673e4d47f30467e78897c5364320e860b.zip
r18294@catbus: nickm | 2008-02-20 22:42:44 -0500
Fix a spelling error and clean up a recent veracode-induced integer overflow check. Both spotted by Chris Palmer. svn:r13639
Diffstat (limited to 'src/common/container.c')
-rw-r--r--src/common/container.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/common/container.c b/src/common/container.c
index b138c9273c..8e507486c8 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -89,10 +89,12 @@ smartlist_add(smartlist_t *sl, void *element)
void
smartlist_add_all(smartlist_t *s1, const smartlist_t *s2)
{
- smartlist_ensure_capacity(s1, s1->num_used + s2->num_used);
- tor_assert(s1->capacity >= s1->num_used+s2->num_used);
+ int new_size = s1->num_used + s2->num_used;
+ tor_assert(new_size >= s1->num_used); /* check for overflow. */
+ smartlist_ensure_capacity(s1, new_size);
+ tor_assert(s1->capacity >= new_size);
memcpy(s1->list + s1->num_used, s2->list, s2->num_used*sizeof(void*));
- s1->num_used += s2->num_used;
+ s1->num_used = new_size;
}
/** Remove all elements E from sl such that E==element. Preserve