Another clang analyzer complaint wrt HT_GENERATE

We're calling mallocfn() and reallocfn() in the HT_GENERATE macro
with the result of a product.  But that makes any sane analyzer
worry about overflow.

This patch keeps HT_GENERATE having its old semantics, since we
aren't the only project using ht.h.  Instead, define a HT_GENERATE2
that takes a reallocarrayfn.
This commit is contained in:
Nick Mathewson
2014-09-02 12:48:34 -04:00
parent e3c143f521
commit 00ffccd9a6
14 changed files with 54 additions and 39 deletions
+2 -2
View File
@@ -62,8 +62,8 @@ static HT_HEAD(process_map, waitpid_callback_t) process_map = HT_INITIALIZER();
HT_PROTOTYPE(process_map, waitpid_callback_t, node, process_map_entry_hash_,
process_map_entries_eq_);
HT_GENERATE(process_map, waitpid_callback_t, node, process_map_entry_hash_,
process_map_entries_eq_, 0.6, malloc, realloc, free);
HT_GENERATE2(process_map, waitpid_callback_t, node, process_map_entry_hash_,
process_map_entries_eq_, 0.6, tor_reallocarray_, tor_free_);
/**
* Begin monitoring the child pid <b>pid</b> to see if we get a SIGCHLD for