Skip to content

Commit c70f2e0

Browse files
[ScanDependency] Fix a container overflow bug when removing arguments
Fix a bug that when the last argument is removed as macro search options, the iterator increment afterwards is going to bring it pass the end of the container. rdar://135366279
1 parent f40c654 commit c70f2e0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ static void removeMacroSearchPaths(std::vector<std::string> &cmd) {
170170
};
171171

172172
// Remove macro search path option and its argument.
173-
for (auto it = cmd.begin(), ie=cmd.end(); it != ie; ++it) {
174-
if (macroSearchOptions.contains(*it) && it + 1 != ie) {
173+
for (auto it = cmd.begin(); it != cmd.end();) {
174+
if (macroSearchOptions.contains(*it) && it + 1 != cmd.end())
175175
it = cmd.erase(it, it + 2);
176-
}
176+
else
177+
++it;
177178
}
178179
}
179180

0 commit comments

Comments
 (0)