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