diff --git a/src/filedef.cpp b/src/filedef.cpp
index 9e8a61c..322c9f8 100644
--- a/src/filedef.cpp
+++ b/src/filedef.cpp
@@ -1657,12 +1657,18 @@ void FileDef::acquireFileVersion()
     }
     const int bufSize=1024;
     char buf[bufSize];
-    int numRead = (int)fread(buf,1,bufSize,f);
+    // read bufSize - 1 bytes (leave space for '\0')
+    const 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)
     {
-      msg("%s\n",m_fileVersion.data());
-    }
+		// add a terminating null character
+		buf[numRead - 1] = '\0'; 
+		if(!(m_fileVersion=QCString(buf,numRead).stripWhiteSpace()).isEmpty())
+		{
+			msg("%s\n",m_fileVersion.data());
+		}
+	}
     else 
     {
       msg("no version available\n");
