Fix a bunch of minor bugs found by Coverity scanner
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9889 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
64ca4638ab
commit
fb51964d01
16 changed files with 99 additions and 40 deletions
|
|
@ -50,9 +50,9 @@ void Swig_cparse_debug_templates(int x) {
|
|||
static int cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) {
|
||||
static int expanded = 0;
|
||||
int ret;
|
||||
String *nodeType = nodeType(n);
|
||||
if (!n)
|
||||
return 0;
|
||||
String *nodeType = nodeType(n);
|
||||
if (Getattr(n, "error"))
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -2500,6 +2500,7 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) {
|
|||
Delete(result_type);
|
||||
Delete(mangled_name);
|
||||
Delete(pl);
|
||||
DelWrapper(wrap);
|
||||
|
||||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "emit_defun: EXIT\n");
|
||||
|
|
@ -2556,6 +2557,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
emit_buffered_defuns(n);
|
||||
emit_dispatch_defun(n);
|
||||
}
|
||||
DelWrapper(wrap);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
@ -2649,6 +2651,8 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
}
|
||||
}
|
||||
|
||||
DelWrapper(wrap);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ void CFFI::emit_defmethod(Node *n) {
|
|||
else
|
||||
Printf(args_placeholder, "%s", argname);
|
||||
|
||||
if (Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0)
|
||||
if (ffitype && Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0)
|
||||
Printf(args_call, " (ff-pointer %s)", argname);
|
||||
else
|
||||
Printf(args_call, " %s", argname);
|
||||
|
|
@ -373,8 +373,10 @@ int CFFI::functionWrapper(Node *n) {
|
|||
if (Getattr(n, "sym:overloaded")) {
|
||||
overname = Getattr(n, "sym:overname");
|
||||
} else {
|
||||
if (!addSymbol(iname, n))
|
||||
if (!addSymbol(iname, n)) {
|
||||
DelWrapper(wrap);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
|
|
@ -479,6 +481,7 @@ int CFFI::functionWrapper(Node *n) {
|
|||
// }
|
||||
|
||||
Delete(wname);
|
||||
DelWrapper(wrap);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,6 +280,11 @@ public:
|
|||
String *outfile = Getattr(n, "outfile");
|
||||
String *outfile_h = Getattr(n, "outfile_h");
|
||||
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
FileErrorDisplay(outfile);
|
||||
|
|
@ -287,6 +292,10 @@ public:
|
|||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
if (!outfile_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime_h = NewFile(outfile_h, "w");
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
|
|
@ -1540,7 +1549,7 @@ public:
|
|||
destruct_methodname = Getattr(attributes, "tmap:csdestruct:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct:methodmodifiers");
|
||||
}
|
||||
if (*Char(tm)) {
|
||||
if (tm && *Char(tm)) {
|
||||
if (!destruct_methodname) {
|
||||
Swig_error(input_file, line_number, "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -672,8 +672,10 @@ public:
|
|||
overname = Getattr(n, "sym:overname");
|
||||
args_passed_as_array = 1;
|
||||
} else {
|
||||
if (!addSymbol(iname, n))
|
||||
return SWIG_ERROR;
|
||||
if (!addSymbol(iname, n)) {
|
||||
DelWrapper(f);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
if (overname) {
|
||||
Append(wname, overname);
|
||||
|
|
@ -1371,6 +1373,7 @@ public:
|
|||
if ((SwigType_type(nctype) == T_USER) && (!is_a_pointer(nctype))) {
|
||||
Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n");
|
||||
Delete(var_name);
|
||||
DelWrapper(f);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
// See if there's a typemap
|
||||
|
|
|
|||
|
|
@ -287,6 +287,11 @@ public:
|
|||
String *outfile = Getattr(n, "outfile");
|
||||
String *outfile_h = Getattr(n, "outfile_h");
|
||||
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
FileErrorDisplay(outfile);
|
||||
|
|
@ -294,6 +299,10 @@ public:
|
|||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
if (!outfile_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime_h = NewFile(outfile_h, "w");
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
|
|
@ -1608,7 +1617,7 @@ public:
|
|||
destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers");
|
||||
}
|
||||
if (*Char(tm)) {
|
||||
if (tm && *Char(tm)) {
|
||||
if (!destruct_methodname) {
|
||||
Swig_error(input_file, line_number,
|
||||
"No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
|
|
|
|||
|
|
@ -397,7 +397,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_mark_arg(i);
|
||||
} else if (strncmp(argv[i], "-I", 2) == 0) {
|
||||
// Add a new directory search path
|
||||
Swig_add_directory((DOH *) Swig_copy_string(argv[i] + 2));
|
||||
char *a = Swig_copy_string(argv[i] + 2);
|
||||
Swig_add_directory((DOH *) a);
|
||||
free(a);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strncmp(argv[i], "-D", 2) == 0) {
|
||||
String *d = NewString(argv[i] + 2);
|
||||
|
|
@ -1064,10 +1066,10 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (dump_top) {
|
||||
Swig_print_tree(top);
|
||||
}
|
||||
if (dump_module) {
|
||||
if (dump_module && top) {
|
||||
Swig_print_tree(Getattr(top, "module"));
|
||||
}
|
||||
if (dump_xml) {
|
||||
if (dump_xml && top) {
|
||||
Swig_print_xml(top, xmlout);
|
||||
}
|
||||
Delete(top);
|
||||
|
|
|
|||
|
|
@ -248,8 +248,10 @@ public:
|
|||
if (Getattr(n, "sym:overloaded")) {
|
||||
overname = Getattr(n, "sym:overname");
|
||||
} else {
|
||||
if (!addSymbol(iname, n))
|
||||
if (!addSymbol(iname, n)) {
|
||||
DelWrapper(f);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
if (overname) {
|
||||
Append(wname, overname);
|
||||
|
|
|
|||
|
|
@ -446,8 +446,10 @@ public:
|
|||
if (isOverloaded) {
|
||||
overname = Getattr(n, "sym:overname");
|
||||
} else {
|
||||
if (!addSymbol(iname, n))
|
||||
if (!addSymbol(iname, n)) {
|
||||
DelWrapper(f);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
if (overname) {
|
||||
Append(wname, overname);
|
||||
|
|
@ -1094,6 +1096,10 @@ public:
|
|||
|
||||
int classHandler(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
|
||||
if (!name)
|
||||
return SWIG_OK;
|
||||
|
||||
String *mangled_sym_name = mangleNameForCaml(name);
|
||||
String *this_class_def = NewString(f_classtemplate);
|
||||
String *name_normalized = normalizeTemplatedClassName(name);
|
||||
|
|
@ -1102,8 +1108,6 @@ public:
|
|||
f_class_ctors = NewString("");
|
||||
bool sizeof_feature = generate_sizeof && isSimpleType(name);
|
||||
|
||||
if (!name)
|
||||
return SWIG_OK;
|
||||
|
||||
classname = mangled_sym_name;
|
||||
classmode = true;
|
||||
|
|
|
|||
|
|
@ -819,6 +819,8 @@ public:
|
|||
addfail = emit_action_code(n, getf, tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0));
|
||||
DelWrapper(setf);
|
||||
DelWrapper(getf);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
Printf(getf->code, " return 1;\n");
|
||||
|
|
@ -1529,6 +1531,7 @@ public:
|
|||
Printf(pragma_include, "%s", buffer);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
} else {
|
||||
Printf(stderr, "%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
|
|
|
|||
|
|
@ -1305,8 +1305,10 @@ public:
|
|||
Delete(wname);
|
||||
wname = NULL;
|
||||
|
||||
if (!(shadow && php_version == 5))
|
||||
if (!(shadow && php_version == 5)) {
|
||||
DelWrapper(f);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
// Handle getters and setters.
|
||||
if (wrapperType == membervar) {
|
||||
|
|
@ -1841,8 +1843,11 @@ public:
|
|||
Printf(output, "\t}\n");
|
||||
Delete(prepare);
|
||||
Delete(invoke);
|
||||
free(arg_values);
|
||||
}
|
||||
|
||||
DelWrapper(f);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2521,6 +2526,7 @@ public:
|
|||
Delete(class_iname);
|
||||
Delete(mget);
|
||||
Delete(mset);
|
||||
DelWrapper(f);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -2644,7 +2650,7 @@ public:
|
|||
char *iname = GetChar(n, "sym:name");
|
||||
|
||||
if (shadow && php_version == 4) {
|
||||
if (strcmp(iname, Char(shadow_classname)) == 0) {
|
||||
if (iname && strcmp(iname, Char(shadow_classname)) == 0) {
|
||||
native_constructor = NATIVE_CONSTRUCTOR;
|
||||
} else {
|
||||
native_constructor = ALTERNATIVE_CONSTRUCTOR;
|
||||
|
|
|
|||
|
|
@ -1600,6 +1600,7 @@ void R::dispatchFunction(Node *n) {
|
|||
Printv(f->code, "\n}", NIL);
|
||||
Wrapper_print(f, sfile);
|
||||
Printv(sfile, "# Dispatch function\n", NIL);
|
||||
DelWrapper(f);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
|
@ -2398,8 +2399,10 @@ int R::classDeclaration(Node *n) {
|
|||
|
||||
|
||||
// OutputArrayMethod(name, class_member_functions, sfile);
|
||||
OutputMemberReferenceMethod(name, 0, class_member_functions, sfile);
|
||||
OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile);
|
||||
if (class_member_functions)
|
||||
OutputMemberReferenceMethod(name, 0, class_member_functions, sfile);
|
||||
if (class_member_set_functions)
|
||||
OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile);
|
||||
|
||||
if(class_member_functions) {
|
||||
Delete(class_member_functions);
|
||||
|
|
|
|||
|
|
@ -987,6 +987,11 @@ public:
|
|||
String *outfile = Getattr(n, "outfile");
|
||||
String *outfile_h = Getattr(n, "outfile_h");
|
||||
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
f_runtime = NewFile(outfile, "w");
|
||||
if (!f_runtime) {
|
||||
FileErrorDisplay(outfile);
|
||||
|
|
@ -994,6 +999,10 @@ public:
|
|||
}
|
||||
|
||||
if (directorsEnabled()) {
|
||||
if (!outfile_h) {
|
||||
Printf(stderr, "Unable to determine outfile_h\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
f_runtime_h = NewFile(outfile_h, "w");
|
||||
if (!f_runtime_h) {
|
||||
FileErrorDisplay(outfile_h);
|
||||
|
|
|
|||
|
|
@ -375,6 +375,7 @@ public:
|
|||
Wrapper *f = NewWrapper();
|
||||
emit_attach_parmmaps(l, f);
|
||||
Setattr(n, "wrap:parms", l);
|
||||
DelWrapper(f);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -593,30 +593,31 @@ public:
|
|||
setf = NewWrapper();
|
||||
setname = Swig_name_set(iname);
|
||||
setfname = Swig_name_wrapper(setname);
|
||||
Printv(setf->def, "SWIGINTERN const char *", setfname,
|
||||
if (setf) {
|
||||
Printv(setf->def, "SWIGINTERN const char *", setfname,
|
||||
"(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2 SWIGUNUSED, int flags) {", NIL);
|
||||
Wrapper_add_local(setf, "value", "Tcl_Obj *value = 0");
|
||||
Wrapper_add_local(setf, "name1o", "Tcl_Obj *name1o = 0");
|
||||
Wrapper_add_local(setf, "value", "Tcl_Obj *value = 0");
|
||||
Wrapper_add_local(setf, "name1o", "Tcl_Obj *name1o = 0");
|
||||
|
||||
if ((tm = Swig_typemap_lookup_new("varin", n, name, 0))) {
|
||||
Replaceall(tm, "$source", "value");
|
||||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$input", "value");
|
||||
Printf(setf->code, "name1o = Tcl_NewStringObj(name1,-1);\n");
|
||||
Printf(setf->code, "value = Tcl_ObjGetVar2(interp, name1o, 0, flags);\n");
|
||||
Printf(setf->code, "Tcl_DecrRefCount(name1o);\n");
|
||||
Printf(setf->code, "if (!value) SWIG_fail;\n");
|
||||
/* Printf(setf->code,"%s\n", tm); */
|
||||
emit_action_code(n, setf, tm);
|
||||
Printf(setf->code, "return NULL;\n");
|
||||
Printf(setf->code, "fail:\n");
|
||||
Printf(setf->code, "return \"%s\";\n", iname);
|
||||
Printf(setf->code, "}\n");
|
||||
if (setf)
|
||||
if ((tm = Swig_typemap_lookup_new("varin", n, name, 0))) {
|
||||
Replaceall(tm, "$source", "value");
|
||||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$input", "value");
|
||||
Printf(setf->code, "name1o = Tcl_NewStringObj(name1,-1);\n");
|
||||
Printf(setf->code, "value = Tcl_ObjGetVar2(interp, name1o, 0, flags);\n");
|
||||
Printf(setf->code, "Tcl_DecrRefCount(name1o);\n");
|
||||
Printf(setf->code, "if (!value) SWIG_fail;\n");
|
||||
/* Printf(setf->code,"%s\n", tm); */
|
||||
emit_action_code(n, setf, tm);
|
||||
Printf(setf->code, "return NULL;\n");
|
||||
Printf(setf->code, "fail:\n");
|
||||
Printf(setf->code, "return \"%s\";\n", iname);
|
||||
Printf(setf->code, "}\n");
|
||||
Wrapper_print(setf, f_wrappers);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
|
||||
readonly = 1;
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
|
||||
readonly = 1;
|
||||
}
|
||||
}
|
||||
DelWrapper(setf);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1250,7 +1250,7 @@ String *Swig_typemap_lookup_new(const String_or_char *op, Node *node, const Stri
|
|||
char *cop = Char(op);
|
||||
/* special case, we need to check for 'ref' call
|
||||
and set the default code 'sdef' */
|
||||
if (Cmp(op, "newfree") == 0) {
|
||||
if (node && Cmp(op, "newfree") == 0) {
|
||||
sdef = Swig_ref_call(node, lname);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue