1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

Avoid comparing with invalidated iterator to end if elements are deleted.

This commit is contained in:
dmiller
2016-09-01 03:34:22 +00:00
parent 3a01e58f36
commit 6ffce766da

View File

@@ -536,8 +536,8 @@ bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
continue; continue;
std::list<UltraProbe *>::iterator nextProbeI; std::list<UltraProbe *>::iterator nextProbeI;
for (std::list<UltraProbe *>::iterator probeI = host->probes_outstanding.begin(), end = host->probes_outstanding.end(); for (std::list<UltraProbe *>::iterator probeI = host->probes_outstanding.begin();
probeI != end && numGoodSD < selectres && host->num_probes_outstanding() > 0; probeI = nextProbeI) { probeI != host->probes_outstanding.end() && numGoodSD < selectres && host->num_probes_outstanding() > 0; probeI = nextProbeI) {
/* handleConnectResult may remove the probe at probeI, which invalidates /* handleConnectResult may remove the probe at probeI, which invalidates
* the iterator. We copy and increment it here instead of in the for-loop * the iterator. We copy and increment it here instead of in the for-loop
* statement to avoid incrementing an invalid iterator */ * statement to avoid incrementing an invalid iterator */