1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-04 20:46:33 +00:00

Handle new_targets memory management within the class.

This commit is contained in:
dmiller
2021-04-27 19:22:10 +00:00
parent bf9d60734d
commit 6b2de50416
3 changed files with 7 additions and 5 deletions

View File

@@ -76,6 +76,10 @@ NewTargets *NewTargets::get (void) {
return new_targets;
}
void NewTargets::free_new_targets (void) {
delete new_targets;
}
NewTargets::NewTargets (void) {
Initialize();
}

View File

@@ -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);

View File

@@ -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);