From 50945a6359c858ac69e51ec4afa8fb703e2d450f Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Mon, 23 May 2016 08:25:11 -0700 Subject: [PATCH] Fixing a few Coverity warnings. --- src/PriorityQueue.h | 2 +- src/Val.cc | 2 +- src/analyzer/protocol/conn-size/ConnSize.cc | 3 ++- src/file_analysis/analyzer/entropy/Entropy.cc | 1 + src/input/Manager.cc | 2 +- src/patricia.c | 2 ++ 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/PriorityQueue.h b/src/PriorityQueue.h index bb1caad592..6fe36f43fe 100644 --- a/src/PriorityQueue.h +++ b/src/PriorityQueue.h @@ -21,7 +21,7 @@ public: void MinimizeTime() { time = -HUGE_VAL; } protected: - PQ_Element() { } + PQ_Element() { time = 0; offset = -1; } double time; int offset; }; diff --git a/src/Val.cc b/src/Val.cc index ed4ca40e14..f008c63787 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -2401,7 +2401,7 @@ bool TableVal::DoSerialize(SerialInfo* info) const } // Serialize index. - if ( ! state->did_index ) + if ( k && ! state->did_index ) { // Indices are rather small, so we disable suspension // here again. diff --git a/src/analyzer/protocol/conn-size/ConnSize.cc b/src/analyzer/protocol/conn-size/ConnSize.cc index 183ee1e233..4fd4154c05 100644 --- a/src/analyzer/protocol/conn-size/ConnSize.cc +++ b/src/analyzer/protocol/conn-size/ConnSize.cc @@ -12,7 +12,8 @@ using namespace analyzer::conn_size; ConnSize_Analyzer::ConnSize_Analyzer(Connection* c) : Analyzer("CONNSIZE", c), - orig_bytes(), resp_bytes(), orig_pkts(), resp_pkts() + orig_bytes(), resp_bytes(), orig_pkts(), resp_pkts(), + orig_bytes_thresh(), resp_bytes_thresh(), orig_pkts_thresh(), resp_pkts_thresh() { } diff --git a/src/file_analysis/analyzer/entropy/Entropy.cc b/src/file_analysis/analyzer/entropy/Entropy.cc index 2a1bc72723..4802224950 100644 --- a/src/file_analysis/analyzer/entropy/Entropy.cc +++ b/src/file_analysis/analyzer/entropy/Entropy.cc @@ -14,6 +14,7 @@ Entropy::Entropy(RecordVal* args, File* file) { //entropy->Init(); entropy = new EntropyVal; + fed = false; } Entropy::~Entropy() diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 6360e440f4..5abba86ea0 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -1204,7 +1204,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const *vals) ih->idxkey = new HashKey(k->Key(), k->Size(), k->Hash()); ih->valhash = valhash; - if ( stream->event && updated ) + if ( oldval && stream->event && updated ) Ref(oldval); // otherwise it is no longer accessible after the assignment stream->tab->Assign(idxval, k, valval); diff --git a/src/patricia.c b/src/patricia.c index 552019be09..5ec6e2a27c 100644 --- a/src/patricia.c +++ b/src/patricia.c @@ -646,6 +646,8 @@ patricia_search_all (patricia_tree_t *patricia, prefix_t *prefix, patricia_node_ // ok, now we have an upper bound of how much we can return. Let's just alloc that... patricia_node_t **outlist = calloc(cnt, sizeof(patricia_node_t*)); + if (outlist == NULL) + out_of_memory("patrica/patricia_search_all: unable to allocate memory"); while (--cnt >= 0) { node = stack[cnt];