X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..7ea515abfb0211078d9ffcd4420ef0b53f3fcabe:/wxPython/src/libpy.c diff --git a/wxPython/src/libpy.c b/wxPython/src/libpy.c index 5841d40a50..6fe6c00bfb 100644 --- a/wxPython/src/libpy.c +++ b/wxPython/src/libpy.c @@ -5,10 +5,14 @@ * Contains variable linking and pointer type-checking code. ************************************************************************/ +#include "Python.h" + +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include "Python.h" /* Definitions for Windows/Unix exporting */ #if defined(_WIN32) || defined(__WIN32__) @@ -313,11 +317,11 @@ SWIG_GetPtr(char *c, void **ptr, char *t) if (*c != '_') { *ptr = (void *) 0; if (strcmp(c,"NULL") == 0) return (char *) 0; - else c; + else return c; } c++; /* Extract hex value from pointer */ - while (d = *c) { + while ((d = *c) != 0) { if ((d >= '0') && (d <= '9')) p = (p << 4) + (d - '0'); else if ((d >= 'a') && (d <= 'f')) @@ -358,7 +362,7 @@ SWIG_GetPtr(char *c, void **ptr, char *t) sp = &SwigPtrTable[start]; /* Try to find a match */ - while (start <= end) { + while (start < end) { /* was "<=" --robin */ if (strncmp(t,sp->name,sp->len) == 0) { name = sp->name; len = sp->len; @@ -398,16 +402,38 @@ SWIGSTATICRUNTIME(char *) SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type) { PyObject *sobj = obj; char *str; + if (!PyString_Check(obj)) { if (!PyInstance_Check(obj) || !(sobj = PyObject_GetAttrString(obj,"this"))) return ""; + // PyObject_GetAttrString increases sobj refcout ! + Py_DECREF(sobj); } str = PyString_AsString(sobj); + if (str == NULL) + return ""; return SWIG_GetPtr(str,ptr,type); } + #ifdef __cplusplus } #endif + + + + + + + + + + + + + + + +