Memory underrun in util.cpp:5584
"Michael McTernan" <[email protected]>
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <004601c5d64f$51f04b30$52161bac@MM1laptop> |
Hi there,
I took the doxygen-1.4.4-20050815.tar.gz CVS tarball and ran it under
valgrind. I found a byte being accessed before the start of a buffer:
// search for trailing empty lines
int b=l-1,bi=-1;
p=s.data()+b;
while (b>=0)
{
c=*--p; <------ Can read before s.data
if (c==' ' || c=='\t' || c=='\r') b--;
else if (c=='\n') bi=b,b--;
else break;
}
I think the problem is that --p occurs before the dereference, and so the
code would be better written as:
while (b>=0)
{
c=*p;
p--;
if (c==' ' || c=='\t' || c=='\r') b--;
This avoids p[-1] being accessed if something like "\n" is in the buffer.
I've not put it into Bugzilla, but let me know if you would prefer it filed
there instead.
Regards,
Mike
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl