ElectricFence

Matthias Andree matthias.andree at gmx.de
Fri Jan 10 18:32:13 CET 2003


On Fri, 10 Jan 2003, Graham Wilson wrote:

> On Thu, Jan 09, 2003 at 11:32:05PM -0500, David Relson wrote:
> > What's interesting about these tests is that bogofilter is run with input 
> > that doesn't contain any tokens.  When the code gets to rstats_print() 
> > there are 0 tokens to print.  This function allocates memory so it can sort 
> > the array of tokens.  With no tokens, the allocation call becomes 
> > xcalloc(0, 4).  By forcing the count to 1 (instead of 0), all the tests 
> > PASS with ElectricFence becomes happy with this test.
> 
> do you mean that you are forcing count to in in xmalloc()?

No. We only do that if the original count was zero AND the underlying
malloc returned NULL. We do that as we don't want to get bogus "out of
memory" errors when someone tries malloc(0). We might also just pass the
NULL, but that makes lint'ing the code harder -- we'd have to declare
the functions /*@null@*/ and would getting warnings all over the place
where the memory is reused.




More information about the bogofilter-dev mailing list