From: Victor Stinner Date: Fri, 5 Dec 2014 21:51:51 +0000 (+0100) Subject: Issue #9647: os.confstr() ensures that the second call to confstr() returns the X-Git-Tag: v3.5.0a1~373 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cbc18f328c7b87cf57763da3c660897cc0c7886c;p=thirdparty%2FPython%2Fcpython.git Issue #9647: os.confstr() ensures that the second call to confstr() returns the same length. --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index eb0a68d947bd..bd7cd8ad483d 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); }