[Coverity] fix issue reported for SWIG_Python_ConvertFunctionPtr

Fix Coverity issue reported for SWIG_Python_ConvertFunctionPtr:

"Execution cannot reach this statement: *ptr = vptr;"

Because if 'ty' is null, then desc becomes null and we return with
SWIG_ERROR. So 'ty' cannot be null at 'if (ty)'.
This commit is contained in:
Mark Dufour 2017-02-14 10:48:30 +01:00 • committed by Olly Betts
commit 21f532975f

View file

@ -1287,6 +1287,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
return SWIG_ConvertPtr(obj, ptr, ty, 0); return SWIG_ConvertPtr(obj, ptr, ty, 0);
} else { } else {
void *vptr = 0; void *vptr = 0;
swig_cast_info *tc;
/* here we get the method pointer for callbacks */ /* here we get the method pointer for callbacks */
const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
@ -1295,17 +1296,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
if (!desc) if (!desc)
return SWIG_ERROR; return SWIG_ERROR;
if (ty) { tc = SWIG_TypeCheck(desc,ty);
swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) {
if (tc) { int newmemory = 0;
int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
*ptr = SWIG_TypeCast(tc,vptr,&newmemory); assert(!newmemory); /* newmemory handling not yet implemented */
assert(!newmemory); /* newmemory handling not yet implemented */
} else {
return SWIG_ERROR;
}
} else { } else {
*ptr = vptr; return SWIG_ERROR;
} }
return SWIG_OK; return SWIG_OK;
} }