summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-12-05 21:51:51 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-12-05 21:51:51 (GMT)
commitcbc18f328c7b87cf57763da3c660897cc0c7886c (patch)
treec3dd0833e072add32680e1ffa45475506717939f /Modules
parentefb4835f36fe20591c9ffbaa412fd77d91d342c5 (diff)
downloadcpython-cbc18f328c7b87cf57763da3c660897cc0c7886c.zip
cpython-cbc18f328c7b87cf57763da3c660897cc0c7886c.tar.gz
cpython-cbc18f328c7b87cf57763da3c660897cc0c7886c.tar.bz2
Issue #9647: os.confstr() ensures that the second call to confstr() returns the
same length.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index eb0a68d..bd7cd8a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -14369,10 +14369,12 @@ os_confstr_impl(PyModuleDef *module, int name)
}
if (len >= sizeof(buffer)) {
+ size_t len2;
char *buf = PyMem_Malloc(len);
if (buf == NULL)
return PyErr_NoMemory();
- confstr(name, buf, len);
+ len2 = confstr(name, buf, len);
+ assert(len == len2);
result = PyUnicode_DecodeFSDefaultAndSize(buf, len-1);
PyMem_Free(buf);
}