Fix mem leak and unchecked dynamic cast reported by Coverity.

This commit is contained in:
Jon Siwek 2014-03-31 16:32:58 -05:00
parent b2f8196dc2
commit acc721c36c
2 changed files with 6 additions and 5 deletions

View file

@ -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());
} }

View file

@ -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;