[Python-checkins] cpython: Fix off-by-one error.
martin.v.loewis
python-checkins at python.org
Sun Oct 23 18:42:03 CEST 2011
http://hg.python.org/cpython/rev/17d046568f0c
changeset: 73067:17d046568f0c
user: Martin v. Löwis <martin at v.loewis.de>
date: Sun Oct 23 18:41:56 2011 +0200
summary:
Fix off-by-one error.
files:
Python/import.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -955,7 +955,7 @@
/* result = pathstr[:fname] + "__pycache__" + SEP +
pathstr[fname:ext] + tag + ".py[co]" */
taglen = strlen(pyc_tag);
- result = PyUnicode_New(ext + pycache_len + taglen + 4,
+ result = PyUnicode_New(ext + pycache_len + 1 + taglen + 4,
PyUnicode_MAX_CHAR_VALUE(pathstr));
if (!result)
return NULL;
@@ -963,7 +963,7 @@
data = PyUnicode_DATA(result);
PyUnicode_CopyCharacters(result, 0, pathstr, 0, fname);
pos = fname;
- for (i = 0; i < pycache_len - 1; i++)
+ for (i = 0; i < pycache_len; i++)
PyUnicode_WRITE(kind, data, pos++, CACHEDIR[i]);
PyUnicode_WRITE(kind, data, pos++, SEP);
PyUnicode_CopyCharacters(result, pos, pathstr,
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list