mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 06:40:48 +00:00
Keep a std::string in scope when accessing its c_str.
The std::string was being created and deleted in a single statement, so its c_str pointer pointed to freed memory. This could be seen with valgrind nmap --exclude foo
This commit is contained in:
parent
50ec56fa67
commit
262ec8f7d7
1 changed files with 3 additions and 3 deletions
|
|
@ -197,9 +197,9 @@ int load_exclude_string(addrset *excludelist, const char *s) {
|
|||
begin = p;
|
||||
while (*p != '\0' && *p != ',')
|
||||
p++;
|
||||
const char * addr = std::string(begin, p - begin).c_str();
|
||||
if (!addrset_add_spec(excludelist,addr, o.af(), 1)){
|
||||
fatal("Invalid address specification: %s", addr);
|
||||
std::string addr_str = std::string(begin, p - begin);
|
||||
if (!addrset_add_spec(excludelist, addr_str.c_str(), o.af(), 1)) {
|
||||
fatal("Invalid address specification: %s", addr_str.c_str());
|
||||
}
|
||||
if (*p == '\0')
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue