fix some potential null pointer usage as reported by CoveriCoverity Prevent
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10607 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
acc2745177
commit
e5acd3b48a
2 changed files with 52 additions and 52 deletions
|
|
@ -2518,6 +2518,8 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
||||||
|
|
||||||
ParmList *parms = CopyParmList(Getattr(n, "parms"));
|
ParmList *parms = CopyParmList(Getattr(n, "parms"));
|
||||||
Wrapper *f = NewWrapper();
|
Wrapper *f = NewWrapper();
|
||||||
|
SwigType *t = Getattr(n, "type");
|
||||||
|
String *name = Getattr(n, "name");
|
||||||
|
|
||||||
String *raw_return_type = Swig_typemap_lookup("ctype", n, "", 0);
|
String *raw_return_type = Swig_typemap_lookup("ctype", n, "", 0);
|
||||||
SwigType *return_type = Swig_cparse_type(raw_return_type);
|
SwigType *return_type = Swig_cparse_type(raw_return_type);
|
||||||
|
|
@ -2556,7 +2558,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
||||||
if (Getattr(n, "overload:ignore")) {
|
if (Getattr(n, "overload:ignore")) {
|
||||||
// if we're the last overload, make sure to force the emit
|
// if we're the last overload, make sure to force the emit
|
||||||
// of the rest of the overloads before we leave.
|
// of the rest of the overloads before we leave.
|
||||||
Printf(stderr, "ignored overload %s(%x)\n", Getattr(n, "name"), Getattr(n, "sym:nextSibling"));
|
Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling"));
|
||||||
if (!Getattr(n, "sym:nextSibling")) {
|
if (!Getattr(n, "sym:nextSibling")) {
|
||||||
update_package_if_needed(n);
|
update_package_if_needed(n);
|
||||||
emit_buffered_defuns(n);
|
emit_buffered_defuns(n);
|
||||||
|
|
@ -2571,7 +2573,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
||||||
int gencomma = 0;
|
int gencomma = 0;
|
||||||
|
|
||||||
#ifdef ALLEGROCL_DEBUG
|
#ifdef ALLEGROCL_DEBUG
|
||||||
Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), Getattr(n, "name"));
|
Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), name);
|
||||||
#endif
|
#endif
|
||||||
// Now walk the function parameter list and generate code to get arguments
|
// Now walk the function parameter list and generate code to get arguments
|
||||||
String *name_and_parms = NewStringf("%s (", mangled);
|
String *name_and_parms = NewStringf("%s (", mangled);
|
||||||
|
|
@ -2625,12 +2627,16 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
||||||
|
|
||||||
String *actioncode = emit_action(n);
|
String *actioncode = emit_action(n);
|
||||||
|
|
||||||
String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||||
Replaceall(result_convert, "$result", "lresult");
|
if (tm) {
|
||||||
Printf(f->code, "%s\n", result_convert);
|
Replaceall(tm, "$result", "lresult");
|
||||||
Printf(f->code, " return lresult;\n");
|
Printf(f->code, "%s\n", tm);
|
||||||
Delete(result_convert);
|
Printf(f->code, " return lresult;\n");
|
||||||
emit_return_variable(n, Getattr(n, "type"), f);
|
Delete(tm);
|
||||||
|
} else {
|
||||||
|
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), name);
|
||||||
|
}
|
||||||
|
emit_return_variable(n, t, f);
|
||||||
|
|
||||||
if (CPlusPlus) {
|
if (CPlusPlus) {
|
||||||
Printf(f->code, " } catch (...) {\n");
|
Printf(f->code, " } catch (...) {\n");
|
||||||
|
|
|
||||||
|
|
@ -1292,56 +1292,50 @@ public:
|
||||||
* which means looking up and registering by typedef and enum name. */
|
* which means looking up and registering by typedef and enum name. */
|
||||||
int enumDeclaration(Node *n) {
|
int enumDeclaration(Node *n) {
|
||||||
String *name = Getattr(n, "name");
|
String *name = Getattr(n, "name");
|
||||||
String *oname = name ? NewString(name) : NULL;
|
if (name) {
|
||||||
/* name is now fully qualified */
|
String *oname = NewString(name);
|
||||||
String *fully_qualified_name = NewString(name);
|
/* name is now fully qualified */
|
||||||
bool seen_enum = false;
|
String *fully_qualified_name = NewString(name);
|
||||||
if (name_qualifier)
|
bool seen_enum = false;
|
||||||
Delete(name_qualifier);
|
if (name_qualifier)
|
||||||
char *strip_position;
|
Delete(name_qualifier);
|
||||||
name_qualifier = fully_qualify_enum_name(n, NewString(""));
|
char *strip_position;
|
||||||
|
name_qualifier = fully_qualify_enum_name(n, NewString(""));
|
||||||
|
|
||||||
/* Recent changes have distrubed enum and template naming again.
|
|
||||||
* Will try to keep it consistent by can't guarantee much given
|
|
||||||
* that these things move around a lot.
|
|
||||||
*
|
|
||||||
* I need to figure out a way to isolate this module better.
|
|
||||||
*/
|
|
||||||
if (oname) {
|
|
||||||
strip_position = strstr(Char(oname), "::");
|
strip_position = strstr(Char(oname), "::");
|
||||||
|
|
||||||
while (strip_position) {
|
while (strip_position) {
|
||||||
strip_position += 2;
|
strip_position += 2;
|
||||||
oname = NewString(strip_position);
|
oname = NewString(strip_position);
|
||||||
strip_position = strstr(Char(oname), "::");
|
strip_position = strstr(Char(oname), "::");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
seen_enum = oname ? (Getattr(seen_enums, fully_qualified_name) ? true : false) : false;
|
|
||||||
|
|
||||||
if (oname && !seen_enum) {
|
|
||||||
const_enum = true;
|
|
||||||
Printf(f_enum_to_int, "| `%s -> (match y with\n", oname);
|
|
||||||
Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname);
|
|
||||||
/* * * * A note about enum name resolution * * * *
|
|
||||||
* This code should now work, but I think we can do a bit better.
|
|
||||||
* The problem I'm having is that swig isn't very precise about
|
|
||||||
* typedef name resolution. My opinion is that SwigType_typedef
|
|
||||||
* resolve_all should *always* return the enum tag if one exists,
|
|
||||||
* rather than the admittedly friendlier enclosing typedef.
|
|
||||||
*
|
|
||||||
* This would make one of the cases below unnecessary.
|
|
||||||
* * * */
|
|
||||||
Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname);
|
|
||||||
if (!strncmp(Char(fully_qualified_name), "enum ", 5)) {
|
|
||||||
String *fq_noenum = NewString(Char(fully_qualified_name) + 5);
|
|
||||||
Printf(f_mlbody,
|
|
||||||
"let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(f_enumtypes_type, "| `%s\n", oname);
|
seen_enum = (Getattr(seen_enums, fully_qualified_name) ? true : false);
|
||||||
Insert(fully_qualified_name, 0, "enum ");
|
|
||||||
Setattr(seen_enums, fully_qualified_name, n);
|
if (!seen_enum) {
|
||||||
|
const_enum = true;
|
||||||
|
Printf(f_enum_to_int, "| `%s -> (match y with\n", oname);
|
||||||
|
Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname);
|
||||||
|
/* * * * A note about enum name resolution * * * *
|
||||||
|
* This code should now work, but I think we can do a bit better.
|
||||||
|
* The problem I'm having is that swig isn't very precise about
|
||||||
|
* typedef name resolution. My opinion is that SwigType_typedef
|
||||||
|
* resolve_all should *always* return the enum tag if one exists,
|
||||||
|
* rather than the admittedly friendlier enclosing typedef.
|
||||||
|
*
|
||||||
|
* This would make one of the cases below unnecessary.
|
||||||
|
* * * */
|
||||||
|
Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname);
|
||||||
|
if (!strncmp(Char(fully_qualified_name), "enum ", 5)) {
|
||||||
|
String *fq_noenum = NewString(Char(fully_qualified_name) + 5);
|
||||||
|
Printf(f_mlbody,
|
||||||
|
"let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Printf(f_enumtypes_type, "| `%s\n", oname);
|
||||||
|
Insert(fully_qualified_name, 0, "enum ");
|
||||||
|
Setattr(seen_enums, fully_qualified_name, n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = Language::enumDeclaration(n);
|
int ret = Language::enumDeclaration(n);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue