]> granicus.if.org Git - php/commitdiff
Fix bug #73954
authorAndrea Faulds <ajf@ajf.me>
Sun, 5 Feb 2017 01:30:20 +0000 (01:30 +0000)
committerAndrea Faulds <ajf@ajf.me>
Sun, 5 Feb 2017 01:30:20 +0000 (01:30 +0000)
NEWS
Zend/configure.in
Zend/tests/bug73954.phpt [new file with mode: 0644]
configure.in

diff --git a/NEWS b/NEWS
index 102c9eae005ff28b79b4d4299a0ccf099c48fcfd..adc80db1d3143acb05f5a055d5b671a68a94d609 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP                                                                        NEWS
     (Nikita)
   . Fixed bug #73998 (array_key_exists fails on arrays created by
     get_object_vars). (mhagstrand)
+  . Fixed bug #73954 (NAN check fails on Alpine Linux with musl). (Andrea)
 
 - GD:
   . Fixed bug #74031 (ReflectionFunction for imagepng is missing last two
index 29551d924c513d05167223c99117b1c898afdabe..3c7915156cb76c7dc840abe2993b7ab1c48f51ae 100644 (file)
@@ -75,7 +75,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
 #elif defined(HAVE_FPCLASS)
 #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
 #else
-#define zend_isnan(a) 0
+#define zend_isnan(a) ((a) != (a))
 #endif
 #endif
 
diff --git a/Zend/tests/bug73954.phpt b/Zend/tests/bug73954.phpt
new file mode 100644 (file)
index 0000000..918f24b
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Bug #73954 (NAN check fails on Alpine Linux with musl)
+--FILE--
+<?php
+
+var_dump(NAN);
+var_dump(is_nan(NAN));
+
+function takes_int(int $int) {
+}
+
+takes_int(NAN);
+
+?>
+--EXPECTF--
+float(NAN)
+bool(true)
+
+Fatal error: Uncaught TypeError: Argument 1 passed to takes_int() must be of the type integer, float given, called in %s on line 9 and defined in %s:6
+Stack trace:
+#0 %s(9): takes_int(NAN)
+#1 {main}
+  thrown in %s on line 6
index a61a85d0fcf1dd2475aed52399f2b8787139851a..b5a3919e5fd54db35151f8e6ff3b4903f73e9f0e 100644 (file)
@@ -80,7 +80,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
 #elif defined(HAVE_FPCLASS)
 #define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
 #else
-#define zend_isnan(a) 0
+#define zend_isnan(a) ((a) != (a))
 #endif
 #endif