Bug 164353

Summary: malloc_usable_size() doesn't return a usable size
Product: [Developer tools] valgrind Reporter: Timo Sirainen <tss>
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: njn
Priority: NOR    
Version: 3.3.0   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:

Description Timo Sirainen 2008-06-18 02:15:59 UTC
A simple program:

char *mem = malloc(n);
memset(mem, 0, malloc_usable_size(mem));

Results in "invalid write of size x", because malloc_usable_size() returns 8
byte padded values. I think it should return the exact allocated value,
otherwise it just gives pointless errors.
Comment 1 Nicholas Nethercote 2009-06-26 04:11:03 UTC
This was fixed a while ago in SVN.  Thanks for the report.