Skip to content

Instantly share code, notes, and snippets.

@srepmub
srepmub / swig_coverity_pytuple_check.patch
Created February 13, 2017 09:50
swig_coverity_pytuple_check.patch
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index a6801fc4e..ae87c606e 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -2542,7 +2542,7 @@ public:
if (!fastunpack) {
Wrapper_add_local(f, "ii", "Py_ssize_t ii");
if (maxargs - (add_self ? 1 : 0) > 0)
- Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
+ Append(f->code, "if (args && !PyTuple_Check(args)) SWIG_fail;\n");
@srepmub
srepmub / swig_coverity_fixmethods.patch
Created February 13, 2017 09:50
swig_coverity_fixmethods.patch
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index 2cc582841..fe45ac941 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -306,9 +306,9 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
char *ndoc = (char*)malloc(ldoc + lptr + 10);
if (ndoc) {
char *buff = ndoc;
- strncpy(buff, methods[i].ml_doc, ldoc);
+ memcpy(buff, methods[i].ml_doc, ldoc);
@srepmub
srepmub / swig_coverity_convertfunctionptr.patch
Created February 13, 2017 09:49
swig_coverity_convertfunctionptr.patch
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index ab1237f62..0974f3061 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -1295,17 +1295,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
if (!desc)
return SWIG_ERROR;
- if (ty) {
- swig_cast_info *tc = SWIG_TypeCheck(desc,ty);