mirror of https://github.com/python/cpython
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:
parent
721e25c653
commit
d233796f7d
|
@ -2308,7 +2308,7 @@ PyImport_ExtendInittab(struct _inittab *newtab)
|
||||||
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
_PyMem_SetDefaultAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
|
||||||
|
|
||||||
/* Allocate new memory for the combined table */
|
/* 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);
|
size_t size = sizeof(struct _inittab) * (i + n + 1);
|
||||||
p = PyMem_RawRealloc(inittab_copy, size);
|
p = PyMem_RawRealloc(inittab_copy, size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue