|
|
c531d3 |
From 21f532975f59f0c156c76cc739f5a93f57d8f6cb Mon Sep 17 00:00:00 2001
|
|
|
c531d3 |
From: Mark Dufour <m.dufour@kopano.com>
|
|
|
c531d3 |
Date: Tue, 14 Feb 2017 10:48:30 +0100
|
|
|
c531d3 |
Subject: [PATCH] [Coverity] fix issue reported for
|
|
|
c531d3 |
SWIG_Python_ConvertFunctionPtr
|
|
|
c531d3 |
|
|
|
c531d3 |
Fix Coverity issue reported for SWIG_Python_ConvertFunctionPtr:
|
|
|
c531d3 |
|
|
|
c531d3 |
"Execution cannot reach this statement: *ptr = vptr;"
|
|
|
c531d3 |
|
|
|
c531d3 |
Because if 'ty' is null, then desc becomes null and we return with
|
|
|
c531d3 |
SWIG_ERROR. So 'ty' cannot be null at 'if (ty)'.
|
|
|
c531d3 |
---
|
|
|
c531d3 |
Lib/python/pyrun.swg | 21 +++++++++------------
|
|
|
c531d3 |
1 file changed, 9 insertions(+), 12 deletions(-)
|
|
|
c531d3 |
|
|
|
c531d3 |
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
|
|
|
c531d3 |
index ab1237f62..939a69204 100644
|
|
|
c531d3 |
--- a/Lib/python/pyrun.swg
|
|
|
c531d3 |
+++ b/Lib/python/pyrun.swg
|
|
|
c531d3 |
@@ -1287,25 +1287,22 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
|
|
|
c531d3 |
return SWIG_ConvertPtr(obj, ptr, ty, 0);
|
|
|
c531d3 |
} else {
|
|
|
c531d3 |
void *vptr = 0;
|
|
|
c531d3 |
-
|
|
|
c531d3 |
+ swig_cast_info *tc;
|
|
|
c531d3 |
+
|
|
|
c531d3 |
/* here we get the method pointer for callbacks */
|
|
|
c531d3 |
const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
|
|
|
c531d3 |
const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
|
|
|
c531d3 |
if (desc)
|
|
|
c531d3 |
desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
|
|
|
c531d3 |
- if (!desc)
|
|
|
c531d3 |
+ if (!desc)
|
|
|
c531d3 |
return SWIG_ERROR;
|
|
|
c531d3 |
- if (ty) {
|
|
|
c531d3 |
- swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
|
|
|
c531d3 |
- if (tc) {
|
|
|
c531d3 |
- int newmemory = 0;
|
|
|
c531d3 |
- *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
|
|
|
c531d3 |
- assert(!newmemory); /* newmemory handling not yet implemented */
|
|
|
c531d3 |
- } else {
|
|
|
c531d3 |
- return SWIG_ERROR;
|
|
|
c531d3 |
- }
|
|
|
c531d3 |
+ tc = SWIG_TypeCheck(desc,ty);
|
|
|
c531d3 |
+ if (tc) {
|
|
|
c531d3 |
+ int newmemory = 0;
|
|
|
c531d3 |
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
|
|
|
c531d3 |
+ assert(!newmemory); /* newmemory handling not yet implemented */
|
|
|
c531d3 |
} else {
|
|
|
c531d3 |
- *ptr = vptr;
|
|
|
c531d3 |
+ return SWIG_ERROR;
|
|
|
c531d3 |
}
|
|
|
c531d3 |
return SWIG_OK;
|
|
|
c531d3 |
}
|
|
|
c531d3 |
--
|
|
|
c531d3 |
2.14.3
|
|
|
c531d3 |
|