A couple null ptr checks.

This commit is contained in:
Jon Siwek 2013-09-25 11:16:46 -05:00
parent daf5d0d098
commit 3c37e818ce
2 changed files with 23 additions and 5 deletions

View file

@ -504,17 +504,35 @@ static void WritePluginComponents(FILE* f, const plugin::Plugin* p)
{ {
switch ( (*it)->Type() ) { switch ( (*it)->Type() ) {
case plugin::component::ANALYZER: case plugin::component::ANALYZER:
WriteAnalyzerComponent(f, {
dynamic_cast<const analyzer::Component*>(*it)); const analyzer::Component* c =
dynamic_cast<const analyzer::Component*>(*it);
if ( c )
WriteAnalyzerComponent(f, c);
else
reporter->InternalError("component type mismatch");
}
break; break;
case plugin::component::FILE_ANALYZER: case plugin::component::FILE_ANALYZER:
WriteAnalyzerComponent(f, {
dynamic_cast<const file_analysis::Component*>(*it)); const file_analysis::Component* c =
dynamic_cast<const file_analysis::Component*>(*it);
if ( c )
WriteAnalyzerComponent(f, c);
else
reporter->InternalError("component type mismatch");
}
break; break;
case plugin::component::READER: case plugin::component::READER:
reporter->InternalError("docs for READER component unimplemented"); reporter->InternalError("docs for READER component unimplemented");
case plugin::component::WRITER: case plugin::component::WRITER:
reporter->InternalError("docs for WRITER component unimplemented"); reporter->InternalError("docs for WRITER component unimplemented");
default: default:
reporter->InternalError("docs for unknown component unimplemented"); reporter->InternalError("docs for unknown component unimplemented");
} }

View file

@ -721,7 +721,7 @@ static char* get_prompt(bool reset_counter = false)
string get_context_description(const Stmt* stmt, const Frame* frame) string get_context_description(const Stmt* stmt, const Frame* frame)
{ {
ODesc d; ODesc d;
const BroFunc* func = frame->GetFunction(); const BroFunc* func = frame ? frame->GetFunction() : 0;
if ( func ) if ( func )
func->DescribeDebug(&d, frame->GetFuncArgs()); func->DescribeDebug(&d, frame->GetFuncArgs());