[Bro-Dev] [JIRA] (BIT-1532) fix memory leak in find_all() and IRC analyzer
Robin Sommer (JIRA)
jira at bro-tracker.atlassian.net
Wed Feb 3 08:51:00 PST 2016
[ https://bro-tracker.atlassian.net/browse/BIT-1532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robin Sommer updated BIT-1532:
------------------------------
Status: Merge Request (was: Open)
> 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
> Fix For: 2.5
>
> 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