more fixes for security and warnings
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7009 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fbdf160f4a
commit
5b74ab97a7
10 changed files with 44 additions and 34 deletions
|
|
@ -34,7 +34,7 @@ SWIGINTERN int
|
||||||
} else {
|
} else {
|
||||||
double d;
|
double d;
|
||||||
if (SWIG_AsVal(double)(o, &d)) {
|
if (SWIG_AsVal(double)(o, &d)) {
|
||||||
if (val) *val = Constructor(d, 0);
|
if (val) *val = Constructor(d, 0.0);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
@ -73,7 +73,7 @@ SWIGINTERN int
|
||||||
double re;
|
double re;
|
||||||
if (SWIG_AsVal(double)(o, &re)) {
|
if (SWIG_AsVal(double)(o, &re)) {
|
||||||
if (SWIG_CheckDoubleInRange(re, -FLT_MAX, FLT_MAX, errmsg)) {
|
if (SWIG_CheckDoubleInRange(re, -FLT_MAX, FLT_MAX, errmsg)) {
|
||||||
if (val) *val = Constructor(SWIG_numeric_cast(re,float), 0);
|
if (val) *val = Constructor(SWIG_numeric_cast(re,float), 0.0);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ namespace swig
|
||||||
return swig::as<T>(item, true);
|
return swig::as<T>(item, true);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
sprintf(msg,"in sequence element %d ", _index);
|
PyOS_snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
|
||||||
if (!PyErr_Occurred()) {
|
if (!PyErr_Occurred()) {
|
||||||
SWIG_type_error(swig::type_name<T>(), item);
|
SWIG_type_error(swig::type_name<T>(), item);
|
||||||
}
|
}
|
||||||
|
|
@ -335,7 +335,7 @@ namespace swig
|
||||||
if (!swig::check<value_type>(item)) {
|
if (!swig::check<value_type>(item)) {
|
||||||
if (set_err) {
|
if (set_err) {
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
sprintf(msg,"in sequence element %d", i);
|
PyOS_snprintf(msg, sizeof(msg), "in sequence element %d", i);
|
||||||
SWIG_type_error(swig::type_name<value_type>(), item);
|
SWIG_type_error(swig::type_name<value_type>(), item);
|
||||||
SWIG_append_errmsg(msg);
|
SWIG_append_errmsg(msg);
|
||||||
}
|
}
|
||||||
|
|
@ -540,7 +540,7 @@ namespace swig
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class PySeq, class Seq>
|
template <class PySeq, class Seq>
|
||||||
inline void
|
static inline void
|
||||||
assign(const PySeq& pyseq, Seq* seq) {
|
assign(const PySeq& pyseq, Seq* seq) {
|
||||||
#ifdef SWIG_STD_NOASSIGN_STL
|
#ifdef SWIG_STD_NOASSIGN_STL
|
||||||
typedef typename PySeq::value_type value_type;
|
typedef typename PySeq::value_type value_type;
|
||||||
|
|
|
||||||
|
|
@ -137,12 +137,15 @@ SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int
|
||||||
swig_varlinkobject *v = (swig_varlinkobject *) p;
|
swig_varlinkobject *v = (swig_varlinkobject *) p;
|
||||||
swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
|
swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
|
||||||
if (gv) {
|
if (gv) {
|
||||||
gv->name = (char *) malloc(strlen(name)+1);
|
size_t size = strlen(name)+1;
|
||||||
strcpy(gv->name,name);
|
gv->name = (char *)malloc(size);
|
||||||
|
if (gv->name) {
|
||||||
|
strncpy(gv->name,name,size);
|
||||||
gv->get_attr = get_attr;
|
gv->get_attr = get_attr;
|
||||||
gv->set_attr = set_attr;
|
gv->set_attr = set_attr;
|
||||||
gv->next = v->vars;
|
gv->next = v->vars;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
v->vars = gv;
|
v->vars = gv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +158,7 @@ SWIGINTERN void
|
||||||
SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
|
SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
|
||||||
PyObject *obj = 0;
|
PyObject *obj = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; constants[i].type; i++) {
|
for (i = 0; constants[i].type; ++i) {
|
||||||
switch(constants[i].type) {
|
switch(constants[i].type) {
|
||||||
case SWIG_PY_INT:
|
case SWIG_PY_INT:
|
||||||
obj = PyInt_FromLong(constants[i].lvalue);
|
obj = PyInt_FromLong(constants[i].lvalue);
|
||||||
|
|
@ -204,7 +207,7 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
|
||||||
int j;
|
int j;
|
||||||
swig_const_info *ci = 0;
|
swig_const_info *ci = 0;
|
||||||
char *name = c + 10;
|
char *name = c + 10;
|
||||||
for (j = 0; const_table[j].type; j++) {
|
for (j = 0; const_table[j].type; ++j) {
|
||||||
if (strncmp(const_table[j].name, name,
|
if (strncmp(const_table[j].name, name,
|
||||||
strlen(const_table[j].name)) == 0) {
|
strlen(const_table[j].name)) == 0) {
|
||||||
ci = &(const_table[j]);
|
ci = &(const_table[j]);
|
||||||
|
|
@ -217,6 +220,7 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
|
||||||
size_t ldoc = (c - methods[i].ml_doc);
|
size_t ldoc = (c - methods[i].ml_doc);
|
||||||
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
|
size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
|
||||||
char *ndoc = (char*)malloc(ldoc + lptr + 10);
|
char *ndoc = (char*)malloc(ldoc + lptr + 10);
|
||||||
|
if (ndoc) {
|
||||||
char *buff = ndoc;
|
char *buff = ndoc;
|
||||||
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue);
|
void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue);
|
||||||
strncpy(buff, methods[i].ml_doc, ldoc);
|
strncpy(buff, methods[i].ml_doc, ldoc);
|
||||||
|
|
@ -228,6 +232,7 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------*
|
/* -----------------------------------------------------------------------------*
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ PySwigObject_oct(PySwigObject *v)
|
||||||
char buf[100];
|
char buf[100];
|
||||||
unsigned long x = (unsigned long)v->ptr;
|
unsigned long x = (unsigned long)v->ptr;
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
strcpy(buf, "0");
|
strncpy(buf, "0",sizeof(buf));
|
||||||
else
|
else
|
||||||
PyOS_snprintf(buf, sizeof(buf), "0%lo", x);
|
PyOS_snprintf(buf, sizeof(buf), "0%lo", x);
|
||||||
return PyString_FromString(buf);
|
return PyString_FromString(buf);
|
||||||
|
|
@ -392,12 +392,15 @@ PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc)
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
void *pack = malloc(size);
|
void *pack = malloc(size);
|
||||||
|
if (pack) {
|
||||||
memcpy(pack, ptr, size);
|
memcpy(pack, ptr, size);
|
||||||
self->pack = pack;
|
self->pack = pack;
|
||||||
self->desc = desc;
|
self->desc = desc;
|
||||||
self->size = size;
|
self->size = size;
|
||||||
return (PyObject *) self;
|
return (PyObject *) self;
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGRUNTIMEINLINE const char *
|
SWIGRUNTIMEINLINE const char *
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
{
|
{
|
||||||
$<ype resultptr;
|
$<ype resultptr;
|
||||||
resultptr = ($<ype) malloc(sizeof($type));
|
resultptr = ($<ype) malloc(sizeof($type));
|
||||||
memmove(resultptr, &$1, sizeof($type));
|
if (resultptr) memmove(resultptr, &$1, sizeof($type));
|
||||||
$result = SWIG_NewPointerObj((void *)(resultptr), $&descriptor, 1);
|
$result = SWIG_NewPointerObj((void *)(resultptr), $&descriptor, 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class PySeq, class K, class T >
|
template <class PySeq, class K, class T >
|
||||||
inline void
|
static inline void
|
||||||
assign(const PySeq& pyseq, std::map<K,T > *map) {
|
assign(const PySeq& pyseq, std::map<K,T > *map) {
|
||||||
typedef typename std::map<K,T>::value_type value_type;
|
typedef typename std::map<K,T>::value_type value_type;
|
||||||
typename PySeq::const_iterator it = pyseq.begin();
|
typename PySeq::const_iterator it = pyseq.begin();
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class PySeq, class K, class T >
|
template <class PySeq, class K, class T >
|
||||||
void assign(const PySeq& pyseq, std::multimap<K,T > *multimap) {
|
static inline void
|
||||||
|
assign(const PySeq& pyseq, std::multimap<K,T > *multimap) {
|
||||||
typedef typename std::map<K,T>::value_type value_type;
|
typedef typename std::map<K,T>::value_type value_type;
|
||||||
typename PySeq::const_iterator it = pyseq.begin();
|
typename PySeq::const_iterator it = pyseq.begin();
|
||||||
for (;it != pyseq.end(); ++it) {
|
for (;it != pyseq.end(); ++it) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class PySeq, class T>
|
template <class PySeq, class T>
|
||||||
void assign(const PySeq& pyseq, std::multiset<T>* seq) {
|
static inline void
|
||||||
|
assign(const PySeq& pyseq, std::multiset<T>* seq) {
|
||||||
#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL
|
#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL
|
||||||
typedef typename PySeq::value_type value_type;
|
typedef typename PySeq::value_type value_type;
|
||||||
typename PySeq::const_iterator it = pyseq.begin();
|
typename PySeq::const_iterator it = pyseq.begin();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class PySeq, class T>
|
template <class PySeq, class T>
|
||||||
void assign(const PySeq& pyseq, std::set<T>* seq) {
|
static inline void
|
||||||
|
assign(const PySeq& pyseq, std::set<T>* seq) {
|
||||||
#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL
|
#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL
|
||||||
typedef typename PySeq::value_type value_type;
|
typedef typename PySeq::value_type value_type;
|
||||||
typename PySeq::const_iterator it = pyseq.begin();
|
typename PySeq::const_iterator it = pyseq.begin();
|
||||||
|
|
|
||||||
|
|
@ -157,9 +157,8 @@ SWIG_TypeCompare(const char *nb, const char *tb) {
|
||||||
|
|
||||||
/* think of this as a c++ template<> or a scheme macro */
|
/* think of this as a c++ template<> or a scheme macro */
|
||||||
#define SWIG_TypeCheck_Template(comparison, ty) \
|
#define SWIG_TypeCheck_Template(comparison, ty) \
|
||||||
do { \
|
if (ty) { \
|
||||||
swig_cast_info *iter; \
|
swig_cast_info *iter; \
|
||||||
if (!ty) return 0; \
|
|
||||||
iter = ty->cast; \
|
iter = ty->cast; \
|
||||||
while (iter) { \
|
while (iter) { \
|
||||||
if (comparison) { \
|
if (comparison) { \
|
||||||
|
|
@ -178,7 +177,7 @@ SWIG_TypeCompare(const char *nb, const char *tb) {
|
||||||
} \
|
} \
|
||||||
iter = iter->next; \
|
iter = iter->next; \
|
||||||
} \
|
} \
|
||||||
} while(0); \
|
} \
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue