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