[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:
parent
9825fcbab5
commit
21f532975f
1 changed files with 9 additions and 12 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue