Skip to content

Instantly share code, notes, and snippets.

@srepmub
Created February 13, 2017 09:49
Show Gist options
  • Save srepmub/184b74150178b171893196bf9638643c to your computer and use it in GitHub Desktop.
Save srepmub/184b74150178b171893196bf9638643c to your computer and use it in GitHub Desktop.
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);
- if (tc) {
- int newmemory = 0;
- *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
- assert(!newmemory); /* newmemory handling not yet implemented */
- } else {
- return SWIG_ERROR;
- }
+ swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
} else {
- *ptr = vptr;
+ return SWIG_ERROR;
}
return SWIG_OK;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment