Fix Coverity 'Uninitialized pointer fields' - member variables are now initialized

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13887 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-11-14 22:17:28 +00:00
commit fd24b188e2
8 changed files with 104 additions and 54 deletions

View file

@ -156,7 +156,9 @@ public:
dmethods_seq(NULL), dmethods_seq(NULL),
dmethods_table(NULL), dmethods_table(NULL),
n_dmethods(0), n_dmethods(0),
n_directors(0) { n_directors(0),
first_class_dmethod(0),
curr_class_dmethod(0) {
/* for now, multiple inheritance in directors is disabled, this /* for now, multiple inheritance in directors is disabled, this
should be easy to implement though */ should be easy to implement though */
director_multiple_inheritance = 0; director_multiple_inheritance = 0;

View file

@ -25,7 +25,6 @@ class D : public Language {
const String *empty_string; const String *empty_string;
const String *public_string; const String *public_string;
const String *protected_string; const String *protected_string;
const String *static_string;
/* /*
* Files and file sections containing C/C++ code. * Files and file sections containing C/C++ code.
@ -274,7 +273,9 @@ public:
dmethods_seq(NULL), dmethods_seq(NULL),
dmethods_table(NULL), dmethods_table(NULL),
n_dmethods(0), n_dmethods(0),
unknown_types(NULL) { unknown_types(NULL),
first_class_dmethod(0),
curr_class_dmethod(0) {
// For now, multiple inheritance with directors is not possible. It should be // For now, multiple inheritance with directors is not possible. It should be
// easy to implement though. // easy to implement though.

View file

@ -132,6 +132,7 @@ public:
variable_name(NULL), variable_name(NULL),
proxy_class_constants_code(NULL), proxy_class_constants_code(NULL),
module_class_constants_code(NULL), module_class_constants_code(NULL),
enum_code(NULL),
package(NULL), package(NULL),
jnipackage(NULL), jnipackage(NULL),
package_path(NULL), package_path(NULL),
@ -151,7 +152,9 @@ public:
dmethods_seq(NULL), dmethods_seq(NULL),
dmethods_table(NULL), dmethods_table(NULL),
n_dmethods(0), n_dmethods(0),
n_directors(0) { n_directors(0),
first_class_dmethod(0),
curr_class_dmethod(0) {
/* for now, multiple inheritance in directors is disabled, this /* for now, multiple inheritance in directors is disabled, this
should be easy to implement though */ should be easy to implement though */
director_multiple_inheritance = 0; director_multiple_inheritance = 0;

View file

@ -145,17 +145,29 @@ public:
* Initialize member data * Initialize member data
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
LUA() { LUA() :
f_begin = 0; f_begin(0),
f_runtime = 0; f_runtime(0),
f_header = 0; f_header(0),
f_wrappers = 0; f_wrappers(0),
f_init = 0; f_init(0),
f_initbeforefunc = 0; f_initbeforefunc(0),
PrefixPlusUnderscore = 0; PrefixPlusUnderscore(0),
s_cmd_tab(0),
s_cmd_tab = s_var_tab = s_const_tab = s_luacode = 0; s_var_tab(0),
current=NO_CPP; s_const_tab(0),
s_methods_tab(0),
s_attr_tab(0),
s_luacode(0),
s_dot_get(0),
s_dot_set(0),
s_vars_meta_tab(0),
have_constructor(0),
have_destructor(0),
destructor_action(0),
class_name(0),
constructor_name(0),
current(NO_CPP) {
} }
/* NEW LANGUAGE NOTE:*********************************************** /* NEW LANGUAGE NOTE:***********************************************

View file

@ -58,9 +58,24 @@ private:
} }
public: public:
OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0), OCTAVE():
f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0), f_begin(0),
s_global_tab(0), s_members_tab(0), class_name(0) { f_runtime(0),
f_header(0),
f_doc(0),
f_wrappers(0),
f_init(0),
f_initbeforefunc(0),
f_directors(0),
f_directors_h(0),
s_global_tab(0),
s_members_tab(0),
class_name(0),
have_constructor(0),
have_destructor(0),
constructor_name(0),
docs(0)
{
/* Add code to manage protected constructors and directors */ /* Add code to manage protected constructors and directors */
director_prot_ctor_code = NewString(""); director_prot_ctor_code = NewString("");
Printv(director_prot_ctor_code, Printv(director_prot_ctor_code,

View file

@ -810,33 +810,37 @@ public:
* *
* Initialize member data * Initialize member data
* --------------------------------------------------------------------- */ * --------------------------------------------------------------------- */
RUBY() :
RUBY() { module(0),
module = 0; modvar(0),
modvar = 0; feature(0),
feature = 0; prefix(0),
prefix = 0; current(0),
last_autodoc = NewString(""); classes(0),
current = NO_CPP; klass(0),
classes = 0; special_methods(0),
klass = 0; f_directors(0),
special_methods = 0; f_directors_h(0),
f_begin = 0; f_directors_helpers(0),
f_runtime = 0; f_begin(0),
f_header = 0; f_runtime(0),
f_wrappers = 0; f_runtime_h(0),
f_init = 0; f_header(0),
f_initbeforefunc = 0; f_wrappers(0),
useGlobalModule = false; f_init(0),
multipleInheritance = false; f_initbeforefunc(0),
director_prot_ctor_code = NewString(""); useGlobalModule(false),
Printv(director_prot_ctor_code, multipleInheritance(false) {
"if ( $comparison ) { /* subclassed */\n", last_autodoc = NewString("");
" $director_new \n", current = NO_CPP;
"} else {\n", " rb_raise(rb_eRuntimeError,\"accessing abstract class or protected constructor\"); \n", " return Qnil;\n", "}\n", NIL); director_prot_ctor_code = NewString("");
director_multiple_inheritance = 0; Printv(director_prot_ctor_code,
director_language = 1; "if ( $comparison ) { /* subclassed */\n",
} " $director_new \n",
"} else {\n", " rb_raise(rb_eRuntimeError,\"accessing abstract class or protected constructor\"); \n", " return Qnil;\n", "}\n", NIL);
director_multiple_inheritance = 0;
director_language = 1;
}
/* --------------------------------------------------------------------- /* ---------------------------------------------------------------------
* main() * main()

View file

@ -24,9 +24,21 @@ S-Exp Options (available with -sexp)\n\
static File *out = 0; static File *out = 0;
class Sexp:public Language { class Sexp:public Language {
public:
int indent_level; int indent_level;
Sexp():indent_level(0) { DOHHash *print_circle_hash;
int print_circle_count;
int hanging_parens;
bool need_whitespace;
bool need_newline;
public:
Sexp():
indent_level(0),
print_circle_hash(0),
print_circle_count(0),
hanging_parens(0),
need_whitespace(0),
need_newline(0) {
} }
virtual ~ Sexp() { virtual ~ Sexp() {
@ -51,12 +63,6 @@ public:
} }
} }
DOHHash *print_circle_hash;
int print_circle_count;
int hanging_parens;
bool need_whitespace;
bool need_newline;
/* Top of the parse tree */ /* Top of the parse tree */
virtual int top(Node *n) { virtual int top(Node *n) {
if (out == 0) { if (out == 0) {

View file

@ -40,7 +40,14 @@ class TypePass:private Dispatcher {
Hash *classhash; Hash *classhash;
List *normalize; List *normalize;
TypePass() { TypePass() :
inclass(0),
module(0),
importmode(0),
nsname(0),
nssymname(0),
classhash(0),
normalize(0) {
} }
/* Normalize a type. Replaces type with fully qualified version */ /* Normalize a type. Replaces type with fully qualified version */