bpo-9566: Fix size_t=>int downcast warnings (#5230)

* Use wider types (int => Py_ssize_t) to avoid integer overflows.
* Fix gc.get_freeze_count(): use Py_ssize_t type rather than int, since gc_list_size() returns a Py_ssize_t.
This commit is contained in:
Victor Stinner 2018-01-18 11:15:25 +01:00 committed by GitHub
parent ab74504346
commit 05d68a8bd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 14 deletions

View file

@ -367,13 +367,12 @@ _Py_FindEnvConfigValue(FILE *env_file, const wchar_t *key,
fseek(env_file, 0, SEEK_SET);
while (!feof(env_file)) {
char * p = fgets(buffer, MAXPATHLEN*2, env_file);
wchar_t *tmpbuffer;
int n;
if (p == NULL) {
break;
}
n = strlen(p);
size_t n = strlen(p);
if (p[n - 1] != '\n') {
/* line has overflowed - bail */
break;
@ -382,7 +381,8 @@ _Py_FindEnvConfigValue(FILE *env_file, const wchar_t *key,
/* Comment - skip */
continue;
}
tmpbuffer = _Py_DecodeUTF8_surrogateescape(buffer, n);
wchar_t *tmpbuffer = _Py_DecodeUTF8_surrogateescape(buffer, n);
if (tmpbuffer) {
wchar_t * state;
wchar_t * tok = wcstok(tmpbuffer, L" \t\r\n", &state);