From 82c6d4740a83bf68b6bb11a0072c28f84739dbcb Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 20 Jun 2014 20:27:17 -0400 Subject: [PATCH] coverity fixes Initializing members, avoiding little memory leaks, all minor stuff. --- csclient.cxx | 3 +-- dwflpp.cxx | 2 +- nsscommon.cxx | 1 + parse.h | 2 +- session.cxx | 1 + stapregex-parse.cxx | 4 ++-- staptree.h | 1 + translator-output.cxx | 5 +++-- 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/csclient.cxx b/csclient.cxx index b0a986ca0..2a3c8b764 100644 --- a/csclient.cxx +++ b/csclient.cxx @@ -3297,8 +3297,7 @@ resolve_host ( if (status != 0) hbuf[0] = '\0'; - resolved_host *new_host = new resolved_host(hbuf, new_address); - cached_hosts.push_back(*new_host); + cached_hosts.push_back(resolved_host(hbuf, new_address)); } } if (addr_info) diff --git a/dwflpp.cxx b/dwflpp.cxx index 22b009f58..c024a68aa 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -1962,7 +1962,7 @@ struct external_function_query { Dwarf_Addr addr; bool resolved; external_function_query(dwflpp* dw, const string& name): - dw(dw), name(name), resolved(false) {} + dw(dw), name(name), addr(0), resolved(false) {} }; int diff --git a/nsscommon.cxx b/nsscommon.cxx index 68b4fdec5..9623fc8c5 100644 --- a/nsscommon.cxx +++ b/nsscommon.cxx @@ -1423,6 +1423,7 @@ read_cert_info_from_file (const string &certPath, string &fingerprint) { nsscommon_error (_F("Could not create arena while decoding certificate from file %s", certPath.c_str ())); + fclose (certFile); goto done; } diff --git a/parse.h b/parse.h index 5140c7740..28e695222 100644 --- a/parse.h +++ b/parse.h @@ -52,7 +52,7 @@ struct token friend class parser; friend class lexer; private: - token() {} + token(): chain(0) {} token(const token& other): location(other.location), type(other.type), content(other.content), msg(other.msg), chain(other.chain) {} diff --git a/session.cxx b/session.cxx index 0ef48455c..f62bda6be 100644 --- a/session.cxx +++ b/session.cxx @@ -252,6 +252,7 @@ systemtap_session::systemtap_session (const systemtap_session& other, pattern_root(new match_node), user_file (other.user_file), dfa_counter(0), + dfa_maxtag (0), need_tagged_dfa(other.need_tagged_dfa), be_derived_probes(0), dwarf_derived_probes(0), diff --git a/stapregex-parse.cxx b/stapregex-parse.cxx index cca248878..cfbe10ab1 100644 --- a/stapregex-parse.cxx +++ b/stapregex-parse.cxx @@ -146,10 +146,10 @@ void print_escaped(std::ostream& o, char c) // ------------------------------------------------------------------------ cursor::cursor() : input(NULL), pos(~0), - last_pos(~0), next_c(0), last_c(0) {} + last_pos(~0), finished(false), next_c(0), last_c(0) {} cursor::cursor(const std::string *input, bool do_unescape) - : input(input), do_unescape(do_unescape), pos(0), last_pos(0) + : input(input), do_unescape(do_unescape), pos(0), last_pos(0), finished(false) { next_c = 0; last_c = 0; finished = ( pos >= input->length() ); diff --git a/staptree.h b/staptree.h index c50e4d7c0..c6fd9e224 100644 --- a/staptree.h +++ b/staptree.h @@ -458,6 +458,7 @@ struct print_format: public expression { flags = 0; widthtype = width_unspecified; + precision = 0; prectype = prec_unspecified; type = conv_unspecified; literal_string.clear(); diff --git a/translator-output.cxx b/translator-output.cxx index 38e627e76..2cf7e69a0 100644 --- a/translator-output.cxx +++ b/translator-output.cxx @@ -15,7 +15,7 @@ using namespace std; translator_output::translator_output (ostream& f): - buf(0), o2 (0), o (f), tablevel (0) + buf(0), o2 (0), o (f), tablevel (0), trailer_p(false) { } @@ -25,7 +25,8 @@ translator_output::translator_output (const string& filename, size_t bufsize): o2 (new ofstream (filename.c_str ())), o (*o2), tablevel (0), - filename (filename) + filename (filename), + trailer_p (false) { o2->rdbuf()->pubsetbuf(buf, bufsize); } -- 2.43.5