Kaydet (Commit) cbc18f32 authored tarafından Victor Stinner's avatar Victor Stinner

Issue #9647: os.confstr() ensures that the second call to confstr() returns the

same length.
üst efb4835f
...@@ -14369,10 +14369,12 @@ os_confstr_impl(PyModuleDef *module, int name) ...@@ -14369,10 +14369,12 @@ os_confstr_impl(PyModuleDef *module, int name)
} }
if (len >= sizeof(buffer)) { if (len >= sizeof(buffer)) {
size_t len2;
char *buf = PyMem_Malloc(len); char *buf = PyMem_Malloc(len);
if (buf == NULL) if (buf == NULL)
return PyErr_NoMemory(); return PyErr_NoMemory();
confstr(name, buf, len); len2 = confstr(name, buf, len);
assert(len == len2);
result = PyUnicode_DecodeFSDefaultAndSize(buf, len-1); result = PyUnicode_DecodeFSDefaultAndSize(buf, len-1);
PyMem_Free(buf); PyMem_Free(buf);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment