Fix misc. Coverity warnings

This commit is contained in:
Jon Siwek 2019-08-14 16:18:44 -07:00
parent 47235b57a6
commit 6255ab6584
5 changed files with 13 additions and 12 deletions

View file

@ -1,4 +1,8 @@
3.1.0-dev.55 | 2019-08-14 16:18:44 -0700
* Fix misc. Coverity warnings (Jon Siwek, Corelight)
3.1.0-dev.54 | 2019-08-14 15:38:02 -0700
* Deprecate int/uint{8,16,32,64} typedefs, replace with actual cstdint types (Tim Wojtulewicz, Corelight)

View file

@ -1 +1 @@
3.1.0-dev.54
3.1.0-dev.55

View file

@ -320,12 +320,11 @@ vector<ParseLocationRec> parse_location_string(const string& s)
vector<ParseLocationRec> result;
result.push_back(ParseLocationRec());
ParseLocationRec& plr = result[0];
const char* full_filename = 0;
// If plrFileAndLine, set this to the filename you want; for
// memory management reasons, the real filename is set when looking
// up the line number to find the corresponding statement.
const char* loc_filename = 0;
std::string loc_filename;
if ( sscanf(s.c_str(), "%d", &plr.line) )
{ // just a line number (implicitly referring to the current file)
@ -357,7 +356,7 @@ vector<ParseLocationRec> parse_location_string(const string& s)
return result;
}
loc_filename = copy_string(path.c_str());
loc_filename = path;
plr.type = plrFileAndLine;
}
}
@ -367,12 +366,11 @@ vector<ParseLocationRec> parse_location_string(const string& s)
auto iter = g_dbgfilemaps.find(loc_filename);
if ( iter == g_dbgfilemaps.end() )
reporter->InternalError("Policy file %s should have been loaded\n",
loc_filename);
loc_filename.data());
if ( plr.line > how_many_lines_in(loc_filename) )
if ( plr.line > how_many_lines_in(loc_filename.data()) )
{
debug_msg("No line %d in %s.\n", plr.line, loc_filename);
delete [] full_filename;
debug_msg("No line %d in %s.\n", plr.line, loc_filename.data());
plr.type = plrUnknown;
return result;
}
@ -399,7 +397,6 @@ vector<ParseLocationRec> parse_location_string(const string& s)
plr.stmt = 0;
}
delete [] full_filename;
return result;
}

View file

@ -204,6 +204,7 @@ RuleMatcher::RuleMatcher(int arg_RE_level)
root = new RuleHdrTest(RuleHdrTest::NOPROT, 0, 0, RuleHdrTest::EQ,
new maskedvalue_list);
RE_level = arg_RE_level;
parse_error = false;
}
RuleMatcher::~RuleMatcher()

View file

@ -171,10 +171,9 @@ ID* install_ID(const char* name, const char* module_name,
else
scope = SCOPE_FUNCTION;
string full_name_str = make_full_var_name(module_name, name);
char* full_name = copy_string(full_name_str.c_str());
string full_name = make_full_var_name(module_name, name);
ID* id = new ID(full_name, scope, is_export);
ID* id = new ID(full_name.data(), scope, is_export);
if ( SCOPE_FUNCTION != scope )
global_scope()->Insert(full_name, id);
else