summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2018-03-09 08:40:59 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-09 11:51:14 (GMT)
commit6f2f9ce331179091c6d5c75d78cdf3f67255ded1 (patch)
tree7e8b7f2c0744029949facaaa6336e0b075f6ab01
parentc1e087a9d3af74299d7681c9f9de59e5977a1539 (diff)
downloadCMake-6f2f9ce331179091c6d5c75d78cdf3f67255ded1.zip
CMake-6f2f9ce331179091c6d5c75d78cdf3f67255ded1.tar.gz
CMake-6f2f9ce331179091c6d5c75d78cdf3f67255ded1.tar.bz2
Autogen: Fix for the empty source file crash in 3.10.2
Issue: #17793
-rw-r--r--Source/cmQtAutoGenerators.cxx20
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index a9c9b9d..f91ebb2 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -80,15 +80,21 @@ static bool ReadFile(std::string& content, std::string const& filename,
std::size_t const length = cmSystemTools::FileLength(filename);
cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary));
if (ifs) {
- content.resize(length);
- ifs.read(&content.front(), content.size());
- if (ifs) {
- success = true;
+ if (length > 0) {
+ content.resize(length);
+ ifs.read(&content.front(), content.size());
+ if (ifs) {
+ success = true;
+ } else {
+ content.clear();
+ if (error != nullptr) {
+ error->append("Reading from the file failed.");
+ }
+ }
} else {
+ // Readable but empty file
content.clear();
- if (error != nullptr) {
- error->append("Reading from the file failed.");
- }
+ success = true;
}
} else if (error != nullptr) {
error->append("Opening the file for reading failed.");