[Bro-Dev] [JIRA] (BIT-1532) fix memory leak in find_all() and IRC analyzer
Dirk Leinenbach (JIRA)
jira at bro-tracker.atlassian.net
Tue Feb 2 11:01:00 PST 2016
Dirk Leinenbach created BIT-1532:
-------------------------------------
Summary: fix memory leak in find_all() and IRC analyzer
Key: BIT-1532
URL: https://bro-tracker.atlassian.net/browse/BIT-1532
Project: Bro Issue Tracker
Issue Type: Patch
Components: Bro
Reporter: Dirk Leinenbach
Attachments: 0001-fix-memory-leaks-in-find_all-and-IRC-analyzer.patch
fix memory leaks in find_all() and IRC analyzer
Running bro with perftools enabled (cf. [1]), I get leak reports, as
soon as my call to find_all() returns a non-empty list.
When changing find_all() in the following way (inspired by code in
IRC.cc), the leak is not reported anymore and my scripts still work as
expected:
old:
function find_all%(str: string, re: pattern%) : string_set
%{
TableVal* a = new TableVal(string_set);
const u_char* s = str->Bytes();
const u_char* e = s + str->Len();
for ( const u_char* t = s; t < e; ++t )
{
int n = re->MatchPrefix(t, e - t);
if ( n >= 0 )
{
a->Assign(new StringVal(n, (const char*) t), 0);
t += n - 1;
}
}
return a;
%}
new:
function find_all%(str: string, re: pattern%) : string_set
%{
TableVal* a = new TableVal(string_set);
const u_char* s = str->Bytes();
const u_char* e = s + str->Len();
for ( const u_char* t = s; t < e; ++t )
{
int n = re->MatchPrefix(t, e - t);
if ( n >= 0 )
{
Val* ma = new StringVal(n, (const char*) t);
a->Assign(ma, 0);
Unref(ma);
t += n - 1;
}
}
return a;
%}
--
This message was sent by Atlassian JIRA
(v7.1.0-OD-05-006#71001)
More information about the bro-dev
mailing list