import.c: Fix a GCC warning (#4822)

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)) {
This commit is contained in:
Victor Stinner 2017-12-12 23:29:28 +01:00 committed by GitHub
parent 721e25c653
commit d233796f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View 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);
}