Handle non-existent module filename extension reliably #543
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ensures that the substr call does not get a parameter that is larger than the string length if there is no extension in the
bmi_lib_file
string.Using the "extensionless" filename for a shared library in a realization config is supposed to work, with ngen attaching whatever extension is typical for the OS. However, the code for doing that does not handle the case correctly. The docs say that std::string's
rfind
method returnsstring::npos
when the string is not found, and thatstring::npos
is -1 ... but the type is unsigned... so it is the max size_t value. This apparently causes the calls to.substr
below to blow up. But... this was working previously, so must be a victim of undefined behavior--despite the fact that the docs forsubstr
say that this should causeout_of_range
to be thrown.Puzzling. See also ca76cc6 and f64ffd3 ... so this has worked in the past as it was.
Additions
Removals
Changes
string::npos
in return ofrfind
Testing
Screenshots
Notes
Todos
Checklist
Testing checklist (automated report can be put here)
Target Environment support