summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorMarkus Wick <markus@swabianinstruments.com>2023-03-29 18:23:02 +0200
committerOlly Betts <olly@survex.com>2023-04-21 11:10:10 +1200
commit69134f462b0deb672c77e5285184045db9e85db8 (patch)
tree0a0f15792c912e7b44f373e6cb7e12f5509d34ba /Lib
parent4ec23f5dcd20ce624f2d5466a0ece36568a6114a (diff)
downloadswig-69134f462b0deb672c77e5285184045db9e85db8.tar.gz
Fix CanCastAsInteger if errno is set.
This method checks if the range of the input variable is fine. However if the errno variable was already set, it fails even for valid inputs. This fixes at least some random failures in the python castmode. Fixes: #2519
Diffstat (limited to 'Lib')
-rw-r--r--Lib/typemaps/primtypes.swg8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg
index dd80eb775..85a0b8d9b 100644
--- a/Lib/typemaps/primtypes.swg
+++ b/Lib/typemaps/primtypes.swg
@@ -252,9 +252,11 @@ SWIGINTERNINLINE int
SWIG_CanCastAsInteger(double *d, double min, double max) {
double x = *d;
if ((min <= x && x <= max)) {
- double fx = floor(x);
- double cx = ceil(x);
- double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+ double fx, cx, rd;
+ errno = 0;
+ fx = floor(x);
+ cx = ceil(x);
+ rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
if ((errno == EDOM) || (errno == ERANGE)) {
errno = 0;
} else {