fix seg fault with feature:callback

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8178 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-01-02 09:50:50 +00:00
commit 716317c25d
3 changed files with 15 additions and 4 deletions

View file

@ -435,8 +435,13 @@ DohGetChar(DOH *obj, const DOH *name) {
DOH *
DohGetFlagAttr(DOH *obj, const DOH *name) {
DOH *val = Getattr(obj,(DOH *) name);
if (!val) return NULL;
return (Strcmp(val, "0") != 0) ? val : NULL;
if (!val) {
return NULL;
} else {
const char *cval = Char(val);
if (!cval) return val;
return (strcmp(cval, "0") != 0) ? val : NULL;
}
}
int

View file

@ -1134,7 +1134,13 @@ DohNewStringf(const DOH *fmt, ...)
* ----------------------------------------------------------------------------- */
int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2) {
return strcmp(Char(s1),Char(s2));
const char *c1 = Char(s1);
const char *c2 = Char(s2);
if (c1 && c2) {
return strcmp(c1, c2);
} else {
return c1 < c2;
}
}
int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n) {

View file

@ -1293,7 +1293,7 @@ public:
Printf(methods,"\t { (char *)\"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS, ", name, function);
}
if (n && GetFlag(n,"feature:callback")) {
if (n && Getattr(n,"feature:callback")) {
if (have_docstring(n)) {
String* ds = docstring(n, AUTODOC_FUNC, "", false);
Replaceall(ds, "\n", "\\n");