mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
Issue #9647: os.confstr() ensures that the second call to confstr() returns the
same length.
This commit is contained in:
parent
efb4835f36
commit
cbc18f328c
1 changed files with 3 additions and 1 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue