Permalink
Browse files

Bug 735587 - [PATCH] Fix a terminating null character after fread in …

…src/filedef.cpp
  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Aug 30, 2014
1 parent c4007c3 commit a4003db44dfb624c03b7e0a518e368d3e4b8c1ca
Showing with 10 additions and 7 deletions.
  1. +10 −7 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");
}
}

0 comments on commit a4003db

Please sign in to comment.