Skip to content

Commit 8fe790b

Browse files
authored
fixed #13922 - fail platform lookup when an invalid file is encountered (danmar#7575)
1 parent a552b26 commit 8fe790b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/platform.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,22 @@ bool Platform::loadFromFile(const char exename[], const std::string &filename, b
219219

220220
// open file..
221221
tinyxml2::XMLDocument doc;
222-
bool success = false;
222+
tinyxml2::XMLError err = tinyxml2::XML_SUCCESS;
223223
for (const std::string & f : filenames) {
224224
if (debug)
225225
std::cout << "try to load platform file '" << f << "' ... ";
226-
if (doc.LoadFile(f.c_str()) == tinyxml2::XML_SUCCESS) {
226+
err = doc.LoadFile(f.c_str());
227+
if (err == tinyxml2::XML_SUCCESS) {
227228
if (debug)
228229
std::cout << "Success" << std::endl;
229-
success = true;
230230
break;
231231
}
232232
if (debug)
233233
std::cout << doc.ErrorStr() << std::endl;
234+
if (err != tinyxml2::XML_ERROR_FILE_NOT_FOUND)
235+
break;
234236
}
235-
if (!success)
237+
if (err != tinyxml2::XML_SUCCESS)
236238
return false;
237239

238240
return loadFromXmlDocument(&doc);

test/cli/lookup_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,6 @@ def test_platform_lookup_nofile(tmpdir):
465465
]
466466

467467

468-
# make sure we bail out when we encounter an invalid file
469-
@pytest.mark.xfail(strict=True) # TODO: does not bail out after it found an invalid file
470468
def test_platform_lookup_invalid(tmpdir):
471469
test_file = os.path.join(tmpdir, 'test.c')
472470
with open(test_file, 'wt'):

0 commit comments

Comments
 (0)