swig/swig-3.0.12-Coverity-fix-issue-reported-for-wrapper-argument-che.patch
Ismail Dönmez 9c69d6a8bc Accepting request 636170 from home:scarabeus_iv:branches:devel:tools:building
- Add patches to build with python 3.7 properly:
  * swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_ConvertF.patch
  * swig-3.0.12-Coverity-fix-issue-reported-for-SWIG_Python_FixMetho.patch
  * swig-3.0.12-Coverity-fix-issue-reported-for-wrapper-argument-che.patch
  * swig-3.0.12-Fix-Coverity-issue-reported-for-setslice-pycontainer.patch
  * swig-3.0.12-Fix-generated-code-for-constant-expressions-containi.patch
  * swig-3.0.12-fix-collections.patch
- Use version req to check for 1500 instead for non-existing release
- Move to generic requires those that are true under both conditions
- Use autopatch to apply all the patches at once

OBS-URL: https://build.opensuse.org/request/show/636170
OBS-URL: https://build.opensuse.org/package/show/devel:tools:building/swig?expand=0&rev=108
2018-09-18 08:10:32 +00:00

42 lines
1.5 KiB
Diff

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