]> granicus.if.org Git - python/commitdiff
import.c: Fix a GCC warning (#4822)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 12 Dec 2017 22:29:28 +0000 (23:29 +0100)
committerGitHub <noreply@github.com>
Tue, 12 Dec 2017 22:29:28 +0000 (23:29 +0100)
Fix the warning:

Python/import.c: warning: comparison between signed and unsigned integer expressions
     if ((i + n + 1) <= PY_SSIZE_T_MAX / sizeof(struct _inittab)) {

Python/import.c

index 892f3d1c6e49aefa4a82ca8989d809dbf5133a92..d5dad1a6a30ad360e60a96c2eae8e3eef8a7d8e0 100644 (file)
@@ -2308,7 +2308,7 @@ PyImport_ExtendInittab(struct _inittab *newtab)
     _PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
 
     /* Allocate new memory for the combined table */
-    if ((i + n + 1) <= PY_SSIZE_T_MAX / sizeof(struct _inittab)) {
+    if ((i + n + 1) <= PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(struct _inittab)) {
         size_t size = sizeof(struct _inittab) * (i + n + 1);
         p = PyMem_RawRealloc(inittab_copy, size);
     }