Ok,
here we go (cf. attachment).
With my older state (2.3.XXX) of bro, all tests still are green after
the patch.
The patch applies cleanly also to the current git head, but there I
didn't execute the test suite.
Best regards,
Dirk
On 02.02.2016 17:21, Robin Sommer wrote:
On Tue, Feb 02, 2016 at 16:33 +0100, you wrote:
Val* ma = new StringVal(n, (const char*) t);
a->Assign(ma, 0);
Unref(ma);
Is my observation correct?
It is, good catch. Assign() take ownership of the value (0 in this
case), but not of the index. Yes, please send a patch for this one and
other instances you find. Thanks,
Robin
--
Dr.-Ing. Dirk Leinenbach - Leitung Softwareentwicklung
consistec Engineering & Consulting GmbH
------------------------------------------------------------------
Europaallee 5 Fon: +49 (0)681 / 959044-0
D-66113 Saarbrücken Fax: +49 (0)681 / 959044-11
http://www.consistec.de e-mail: dirk.leinenb...@consistec.de
Registergericht: Amtsgericht Saarbrücken
Registerblatt: HRB12003
Geschäftsführer: Dr. Thomas Sinnwell, Volker Leiendecker, Stefan Sinnwell
>From f0f66eedcd236966e1bde04afa95b4cf11cc4328 Mon Sep 17 00:00:00 2001
From: Dirk Leinenbach <dirk.leinenb...@consistec.de>
Date: Tue, 2 Feb 2016 17:33:50 +0100
Subject: [PATCH] fix memory leaks in find_all() and IRC analyzer
---
src/analyzer/protocol/irc/IRC.cc | 4 +++-
src/strings.bif | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/analyzer/protocol/irc/IRC.cc b/src/analyzer/protocol/irc/IRC.cc
index 96449ea..0fe9bcd 100644
--- a/src/analyzer/protocol/irc/IRC.cc
+++ b/src/analyzer/protocol/irc/IRC.cc
@@ -268,7 +268,9 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
{
if ( parts[i][0] == '@' )
parts[i] = parts[i].substr(1);
- set->Assign(new StringVal(parts[i].c_str()), 0);
+ Val* idx = new StringVal(parts[i].c_str());
+ set->Assign(idx, 0);
+ Unref(idx);
}
vl->append(set);
diff --git a/src/strings.bif b/src/strings.bif
index ebee7d9..914baae 100644
--- a/src/strings.bif
+++ b/src/strings.bif
@@ -1161,7 +1161,9 @@ function find_all%(str: string, re: pattern%) : string_set
int n = re->MatchPrefix(t, e - t);
if ( n >= 0 )
{
- a->Assign(new StringVal(n, (const char*) t), 0);
+ Val* idx = new StringVal(n, (const char*) t);
+ a->Assign(idx, 0);
+ Unref(idx);
t += n - 1;
}
}
--
1.7.10.4
_______________________________________________
bro-dev mailing list
bro-dev@bro.org
http://mailman.icsi.berkeley.edu/mailman/listinfo/bro-dev