diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2014-08-30 17:36:34 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2014-08-30 17:36:34 (GMT) |
commit | a4003db44dfb624c03b7e0a518e368d3e4b8c1ca (patch) | |
tree | ba5a0d259a4d47bf88a44931156771ab0202e6ca /src/filedef.cpp | |
parent | c4007c3abea9c8494bf32181a1352b5366bede69 (diff) | |
download | Doxygen-a4003db44dfb624c03b7e0a518e368d3e4b8c1ca.zip Doxygen-a4003db44dfb624c03b7e0a518e368d3e4b8c1ca.tar.gz Doxygen-a4003db44dfb624c03b7e0a518e368d3e4b8c1ca.tar.bz2 |
Bug 735587 - [PATCH] Fix a terminating null character after fread in src/filedef.cpp
Diffstat (limited to 'src/filedef.cpp')
-rw-r--r-- | src/filedef.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/filedef.cpp b/src/filedef.cpp index 9e8a61c..1b58cdf 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -1657,16 +1657,19 @@ void FileDef::acquireFileVersion() } const int bufSize=1024; char buf[bufSize]; - int numRead = (int)fread(buf,1,bufSize,f); + int numRead = (int)fread(buf,1,bufSize-1,f); portable_pclose(f); - if (numRead>0 && !(m_fileVersion=QCString(buf,numRead).stripWhiteSpace()).isEmpty()) + if (numRead>0 && numRead<bufSize) { - msg("%s\n",m_fileVersion.data()); - } - else - { - msg("no version available\n"); + buf[numRead]='\0'; + m_fileVersion=QCString(buf,numRead).stripWhiteSpace(); + if (!m_fileVersion.isEmpty()) + { + msg("%s\n",m_fileVersion.data()); + return; + } } + msg("no version available\n"); } } |