[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnash-commit] /srv/bzr/gnash/trunk r11776: we need to make the stri
From: |
strk |
Subject: |
Re: [Gnash-commit] /srv/bzr/gnash/trunk r11776: we need to make the string one character larger to keep valgrind happy. |
Date: |
Wed, 20 Jan 2010 16:58:06 +0100 |
On Tue, Jan 19, 2010 at 05:29:40PM -0700, Rob Savoye wrote:
> ------------------------------------------------------------
> revno: 11776
> committer: Rob Savoye <address@hidden>
> branch nick: trunk
> timestamp: Tue 2010-01-19 17:29:40 -0700
> message:
> we need to make the string one character larger to keep valgrind happy.
> - string head(reinterpret_cast<const char *>(buf->reference()));
> + string head(reinterpret_cast<const char *>(buf->reference()),
> buf->size() + 1);
If valgrind was not happy above it means that the string in your buffer
wasn't NULL-terminated. By passing a second argument to std::string constructor
you instruct it to stop after reading those many bytes, no matter
null-termination.
I'm telling just in case the actual memory allocated for the buffer was
buf->size()
and not buf->size()+1, in which case the above would still be a memory error
even
if it valgrind doesn't complain (maybe allocated size is bigger than
registered).
--strk;
() Free GIS & Flash consultant/developer
/\ http://foo.keybit.net/~strk/services.html