diff --git a/NewTargets.cc b/NewTargets.cc index f9d5a0627..b1b3402ae 100644 --- a/NewTargets.cc +++ b/NewTargets.cc @@ -76,6 +76,10 @@ NewTargets *NewTargets::get (void) { return new_targets; } +void NewTargets::free_new_targets (void) { + delete new_targets; +} + NewTargets::NewTargets (void) { Initialize(); } diff --git a/NewTargets.h b/NewTargets.h index 6cd679924..14db4cdcb 100644 --- a/NewTargets.h +++ b/NewTargets.h @@ -90,6 +90,8 @@ public: /* get the new_targets object */ static NewTargets *get (void); + /* Free the new_targets object. */ + static void free_new_targets (void); /* insert targets to the new_targets_queue */ static unsigned long insert (const char *target); diff --git a/nmap.cc b/nmap.cc index 40124103e..7a821d572 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1778,8 +1778,6 @@ int nmap_main(int argc, char *argv[]) { char mytime[128]; struct addrset *exclude_group; #ifndef NOLUA - /* Only NSE scripts can add targets */ - NewTargets *new_targets = NULL; /* Pre-Scan and Post-Scan script results datastructure */ ScriptResults *script_scan_results = NULL; #endif @@ -2022,7 +2020,6 @@ int nmap_main(int argc, char *argv[]) { /* Run the script pre-scanning phase */ if (o.script) { - new_targets = NewTargets::get(); script_scan_results = get_script_scan_results_obj(); script_scan(Targets, SCRIPT_PRE_SCAN); printscriptresults(script_scan_results, SCRIPT_PRE_SCAN); @@ -2288,12 +2285,11 @@ int nmap_main(int argc, char *argv[]) { sr.clear(); } script_scan_results->clear(); - delete new_targets; - new_targets = NULL; } #endif addrset_free(exclude_group); + NewTargets::free_new_targets(); if (o.inputfd != NULL) fclose(o.inputfd);