[Python-checkins] import.c: Fix a GCC warning (#4822)
Victor Stinner
webhook-mailer at python.org
Tue Dec 12 17:29:30 EST 2017
https://github.com/python/cpython/commit/d233796f7d444c67fe51b7dd9521d548e650286f
commit: d233796f7d444c67fe51b7dd9521d548e650286f
branch: master
author: Victor Stinner <victor.stinner at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017年12月12日T23:29:28+01:00
summary:
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)) {
files:
M Python/import.c
diff --git a/Python/import.c b/Python/import.c
index 892f3d1c6e4..d5dad1a6a30 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -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);
}
More information about the Python-checkins
mailing list