From e9c18b51a31fb1a7e6aba802d8fd1cc16f4927f7 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 8 Jun 2012 10:11:54 -0500 Subject: [PATCH] Add more error handling code to logging of enum vals. (addresses #829) If lookup of enum name by value fails, an error is now sent through the reporter framework and the value logged will be an empty string (as opposed to trying to construct a string with null pointer which throws a logic_error and aborts Bro). --- src/logging/Manager.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index baf832e6a9..f0b5cc1748 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -819,7 +819,13 @@ threading::Value* Manager::ValToLogVal(Val* val, BroType* ty) const char* s = val->Type()->AsEnumType()->Lookup(val->InternalInt()); - lval->val.string_val = new string(s); + if ( s ) + lval->val.string_val = new string(s); + else + { + val->Type()->Error("enum type does not contain value", val); + lval->val.string_val = new string(); + } break; }