Skip to content

Commit f1dde51

Browse files
authored
Merge pull request #42007 from DougGregor/std-next-ub-silgen-bridging
Eliminate undefined behavior where we call `next` on a past-the-end iterator
2 parents 71c8c33 + 9343446 commit f1dde51

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/SILGen/SILGenBridging.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,8 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
18181818

18191819
auto directResults = substConv.getDirectSILResults();
18201820
auto hasMultipleDirectResults
1821-
= std::next(directResults.begin()) != directResults.end();
1821+
= !directResults.empty() &&
1822+
std::next(directResults.begin()) != directResults.end();
18221823

18231824
for (unsigned paramI : indices(completionTy->getParameters())) {
18241825
if (errorParamIndex && paramI == *errorParamIndex) {

0 commit comments

Comments
 (0)