diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2019-04-13 16:55:36 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-04-15 14:51:36 -0400 |
commit | 670d0f9f5bb7d73ad236a035ed7bd69e96cadd41 (patch) | |
tree | 5d4f87fb1c73b6ffce1afaf42efc4296339bdfc2 /src | |
parent | 5a0c8579964aa1d27dd9be35afda5e7226c31fb4 (diff) | |
download | tor-670d0f9f5bb7d73ad236a035ed7bd69e96cadd41.tar.gz tor-670d0f9f5bb7d73ad236a035ed7bd69e96cadd41.zip |
Clear memory in smartlist_remove_keeporder.
The smartlist functions take great care to reset unused pointers inside
the smartlist memory to NULL.
The function smartlist_remove_keeporder does not clear memory in such
way when elements have been removed. Therefore call memset after the
for-loop that removes elements. If no element is removed, it is
effectively a no-op.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/smartlist_core/smartlist_core.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib/smartlist_core/smartlist_core.c b/src/lib/smartlist_core/smartlist_core.c index 5947e76271..6b0a305a93 100644 --- a/src/lib/smartlist_core/smartlist_core.c +++ b/src/lib/smartlist_core/smartlist_core.c @@ -177,6 +177,8 @@ smartlist_remove_keeporder(smartlist_t *sl, const void *element) sl->list[i++] = sl->list[j]; } } + memset(sl->list + sl->num_used, 0, + sizeof(void *) * (num_used_orig - sl->num_used)); } /** If <b>sl</b> is nonempty, remove and return the final element. Otherwise, |