Skip to main content.
home | support | download

Back to List Archive

Re: Memory overwrite in 2.4?

From: <moseley(at)not-real.hank.org>
Date: Tue Nov 11 2003 - 16:46:15 GMT
On Tue, Nov 11, 2003 at 08:13:42AM -0800, Mark Fletcher wrote:
> Running some code under valgrind, I think I came across a memory 
> allocation error. In 2.4, in src/header.c, line 180, it currently is:
> 
> sw->index_names = (const char **)emalloc( sizeof(char *) + 
> (1+index_count) );
> 
> But shouldn't the size of the emalloc be sizeof(char*)*(1+index_count)?

Yes, it should be.

That's not used by swish-e (the binary), but is available in the Swish C 
API -- I see its only used in libtest.c.  I guess I never tested with 
enough index file names to see it as a segfault.

Thanks Mark for that catch.

How do you like valgrind?  I've looked at it but never had a chance to 
run it.  Is it reporting anything else?



-- 
Bill Moseley
moseley@hank.org
Received on Tue Nov 11 16:46:24 2003