Browse Source

Autogen: Fix for the empty source file crash in 3.10.2

Issue: #17793
pull/320/head
Sebastian Holtermann 8 years ago
committed by Brad King
parent
commit
6f2f9ce331
  1. 20
      Source/cmQtAutoGenerators.cxx

20
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); std::size_t const length = cmSystemTools::FileLength(filename);
cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary)); cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary));
if (ifs) { 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 { } else {
// Readable but empty file
content.clear(); content.clear();
if (error != nullptr) {
error->append("Reading from the file failed.");
}
success = true;
} }
} else if (error != nullptr) { } else if (error != nullptr) {
error->append("Opening the file for reading failed."); error->append("Opening the file for reading failed.");

Loading…
Cancel
Save