]> granicus.if.org Git - python/commitdiff
Issue #9647: os.confstr() ensures that the second call to confstr() returns the
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 5 Dec 2014 21:51:51 +0000 (22:51 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 5 Dec 2014 21:51:51 +0000 (22:51 +0100)
same length.

Modules/posixmodule.c

index eb0a68d947bdac5c21bbee9413b19584972b2585..bd7cd8ad483d4478ad8284e8f945df6c4a5aad74 100644 (file)
@@ -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);
     }