Bug 164353 - malloc_usable_size() doesn't return a usable size
Summary: malloc_usable_size() doesn't return a usable size
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.3.0
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-18 02:15 UTC by Timo Sirainen
Modified: 2009-06-26 04:11 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.