diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2013-09-08 14:10:13 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2013-09-08 14:10:13 (GMT) |
commit | 1f44278e8612c5c2567046f5bd6a82eacccc1e2a (patch) | |
tree | 15a5e849ea79e8aad560cb40091a84e8a6c08403 /src | |
parent | 5386a768aad6ae7f00353f20bbd3cb60ccb0349e (diff) | |
download | Doxygen-1f44278e8612c5c2567046f5bd6a82eacccc1e2a.zip Doxygen-1f44278e8612c5c2567046f5bd6a82eacccc1e2a.tar.gz Doxygen-1f44278e8612c5c2567046f5bd6a82eacccc1e2a.tar.bz2 |
Avoid accessing uninitialized memory in fileToString
Diffstat (limited to 'src')
-rw-r--r-- | src/bufstr.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/bufstr.h b/src/bufstr.h index 427b012..cfb89c4 100644 --- a/src/bufstr.h +++ b/src/bufstr.h @@ -33,7 +33,7 @@ class BufStr BufStr(int size) : m_size(size), m_writeOffset(0), m_spareRoom(10240), m_buf(0) { - m_buf = (char *)malloc(size); + m_buf = (char *)calloc(size,1); } ~BufStr() { @@ -62,12 +62,17 @@ class BufStr } void resize( uint newlen ) { + uint oldsize = m_size; m_size=newlen; if (m_writeOffset>=m_size) // offset out of range -> enlarge { m_size=m_writeOffset+m_spareRoom; } m_buf = (char *)realloc(m_buf,m_size); + if (m_size>oldsize) + { + memset(m_buf+oldsize,0,m_size-oldsize); + } } int size() const { |