diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-10-19 23:19:42 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-10-19 23:19:42 -0400 |
commit | afc76a4e714a192e76281793f39c412c87964e46 (patch) | |
tree | aca0d0ad0aca768f9fe2ce5426662dc81d933813 /src/common/container.c | |
parent | f6296870535ef3a37bbf5b5b92b393f9c6b7c0a2 (diff) | |
download | tor-afc76a4e714a192e76281793f39c412c87964e46.tar.gz tor-afc76a4e714a192e76281793f39c412c87964e46.zip |
Fix two bugs found by Coverity scan.
One was a simple buffer overrun; the other was a high-speed pointer
collision. Both were introduced by my microdescs branch.
Diffstat (limited to 'src/common/container.c')
-rw-r--r-- | src/common/container.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/container.c b/src/common/container.c index 4fb94d3f7c..f3540f74d8 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -470,26 +470,26 @@ smartlist_get_most_frequent(const smartlist_t *sl, const void *most_frequent = NULL; int most_frequent_count = 0; - const void **cur = NULL; + const void *cur = NULL; int i, count=0; if (!sl->num_used) return NULL; for (i = 0; i < sl->num_used; ++i) { const void *item = sl->list[i]; - if (cur && 0 == compare(cur, &item)) { + if (cur && 0 == compare(&cur, &item)) { ++count; } else { if (cur && count >= most_frequent_count) { - most_frequent = *cur; + most_frequent = cur; most_frequent_count = count; } - cur = &item; + cur = item; count = 1; } } if (cur && count >= most_frequent_count) { - most_frequent = *cur; + most_frequent = cur; most_frequent_count = count; } return (void*)most_frequent; |