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