mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Fix mem leak and unchecked dynamic cast reported by Coverity.
This commit is contained in:
parent
b2f8196dc2
commit
acc721c36c
2 changed files with 6 additions and 5 deletions
|
@ -686,6 +686,10 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state,
|
||||||
loop_over_list(r->actions, rai)
|
loop_over_list(r->actions, rai)
|
||||||
{
|
{
|
||||||
const RuleActionMIME* ram = dynamic_cast<const RuleActionMIME*>(r->actions[rai]);
|
const RuleActionMIME* ram = dynamic_cast<const RuleActionMIME*>(r->actions[rai]);
|
||||||
|
|
||||||
|
if ( ! ram )
|
||||||
|
continue;
|
||||||
|
|
||||||
set<string>& ss = (*rval)[ram->GetStrength()];
|
set<string>& ss = (*rval)[ram->GetStrength()];
|
||||||
ss.insert(ram->GetMIME());
|
ss.insert(ram->GetMIME());
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,12 +49,9 @@ void File_Analyzer::Done()
|
||||||
|
|
||||||
void File_Analyzer::Identify()
|
void File_Analyzer::Identify()
|
||||||
{
|
{
|
||||||
RuleFileMagicState* fms = rule_matcher->InitFileMagic();
|
|
||||||
RuleMatcher::MIME_Matches matches;
|
RuleMatcher::MIME_Matches matches;
|
||||||
|
file_mgr->DetectMIME(reinterpret_cast<const u_char*>(buffer), buffer_len,
|
||||||
rule_matcher->Match(fms, reinterpret_cast<const u_char*>(buffer),
|
&matches);
|
||||||
buffer_len, &matches);
|
|
||||||
|
|
||||||
string match = matches.empty() ? "<unknown>"
|
string match = matches.empty() ? "<unknown>"
|
||||||
: *(matches.begin()->second.begin());
|
: *(matches.begin()->second.begin());
|
||||||
val_list* vl = new val_list;
|
val_list* vl = new val_list;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue