|
|
c531d3 |
From 13eeebd2fb3005abc876957c68bde6a92510aa44 Mon Sep 17 00:00:00 2001
|
|
|
c531d3 |
From: Mark Dufour <m.dufour@kopano.com>
|
|
|
c531d3 |
Date: Tue, 14 Feb 2017 10:53:14 +0100
|
|
|
c531d3 |
Subject: [PATCH] [Coverity] fix issue reported for wrapper argument checking
|
|
|
c531d3 |
|
|
|
c531d3 |
Fix Coverity issue reported for wrapper argument checking:
|
|
|
c531d3 |
|
|
|
c531d3 |
"Null-checking args suggests that it may be null, but it has already
|
|
|
c531d3 |
been dereferenced on all paths leading to the check."
|
|
|
c531d3 |
|
|
|
c531d3 |
So 'args' is null checked, but after dereferencing it with
|
|
|
c531d3 |
PyTuple_Check(args).
|
|
|
c531d3 |
---
|
|
|
c531d3 |
Source/Modules/python.cxx | 11 ++++++++---
|
|
|
c531d3 |
1 file changed, 8 insertions(+), 3 deletions(-)
|
|
|
c531d3 |
|
|
|
c531d3 |
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
|
|
|
c531d3 |
index a6801fc4e..5e058e773 100644
|
|
|
c531d3 |
--- a/Source/Modules/python.cxx
|
|
|
c531d3 |
+++ b/Source/Modules/python.cxx
|
|
|
c531d3 |
@@ -2541,9 +2541,14 @@ public:
|
|
|
c531d3 |
|
|
|
c531d3 |
if (!fastunpack) {
|
|
|
c531d3 |
Wrapper_add_local(f, "ii", "Py_ssize_t ii");
|
|
|
c531d3 |
- if (maxargs - (add_self ? 1 : 0) > 0)
|
|
|
c531d3 |
- Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
|
|
|
c531d3 |
- Append(f->code, "argc = args ? PyObject_Length(args) : 0;\n");
|
|
|
c531d3 |
+
|
|
|
c531d3 |
+ if (maxargs - (add_self ? 1 : 0) > 0) {
|
|
|
c531d3 |
+ Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n");
|
|
|
c531d3 |
+ Append(f->code, "argc = PyObject_Length(args);\n");
|
|
|
c531d3 |
+ } else {
|
|
|
c531d3 |
+ Append(f->code, "argc = args ? PyObject_Length(args) : 0;\n");
|
|
|
c531d3 |
+ }
|
|
|
c531d3 |
+
|
|
|
c531d3 |
if (add_self)
|
|
|
c531d3 |
Append(f->code, "argv[0] = self;\n");
|
|
|
c531d3 |
Printf(f->code, "for (ii = 0; (ii < %d) && (ii < argc); ii++) {\n", add_self ? maxargs - 1 : maxargs);
|
|
|
c531d3 |
--
|
|
|
c531d3 |
2.14.3
|
|
|
c531d3 |
|