summaryrefslogtreecommitdiff
path: root/Python/pathconfig.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2018-01-18 11:15:25 +0100
committerGitHub <noreply@github.com>2018-01-18 11:15:25 +0100
commit05d68a8bd84cb141be9f9335f5b3540f15a989c4 (patch)
treea4e48a3b3c5b46422f83ffb9b4314eb8ea344325 /Python/pathconfig.c
parentab74504346a6e2569b3255b7b621c589716888c4 (diff)
downloadcpython-git-05d68a8bd84cb141be9f9335f5b3540f15a989c4.tar.gz
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.
Diffstat (limited to 'Python/pathconfig.c')
-rw-r--r--Python/pathconfig.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/pathconfig.c b/Python/pathconfig.c
index 7ebd69bf62..6de5481bc8 100644
--- a/Python/pathconfig.c
+++ b/Python/pathconfig.c
@@ -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);