]> granicus.if.org Git - python/commitdiff
bpo-31474: Fix -Wint-in-bool-context warnings (#3581)
authorChristian Heimes <christian@python.org>
Fri, 15 Sep 2017 18:27:23 +0000 (20:27 +0200)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2017 18:27:23 +0000 (20:27 +0200)
Signed-off-by: Christian Heimes <christian@python.org>
Include/pymem.h
Misc/NEWS.d/next/Build/2017-09-14-19-38-19.bpo-31474.0s_mpD.rst [new file with mode: 0644]

index 10b5bea5eb892914c9d2b647ddbb8a06d5585c88..2c239df590d7a5dd3dd5393977da25f68538c148 100644 (file)
@@ -72,9 +72,9 @@ PyAPI_FUNC(void) PyMem_Free(void *);
 /* Returns NULL to indicate error if a negative size or size larger than
    Py_ssize_t can represent is supplied.  Helps prevents security holes. */
 #define PyMem_MALLOC(n)                ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \
-                               : malloc((n) ? (n) : 1))
+                               : malloc(((n) != 0) ? (n) : 1))
 #define PyMem_REALLOC(p, n)    ((size_t)(n) > (size_t)PY_SSIZE_T_MAX  ? NULL \
-                               : realloc((p), (n) ? (n) : 1))
+                               : realloc((p), ((n) != 0) ? (n) : 1))
 #define PyMem_FREE             free
 
 #endif /* PYMALLOC_DEBUG */
diff --git a/Misc/NEWS.d/next/Build/2017-09-14-19-38-19.bpo-31474.0s_mpD.rst b/Misc/NEWS.d/next/Build/2017-09-14-19-38-19.bpo-31474.0s_mpD.rst
new file mode 100644 (file)
index 0000000..41505aa
--- /dev/null
@@ -0,0 +1 @@
+Fix -Wint-in-bool-context warnings in PyMem_MALLOC and PyMem_REALLOC macros