[Python-checkins] r45576 - python/trunk/Modules/posixmodule.c
neal.norwitz
python-checkins at python.org
Thu Apr 20 08:56:06 CEST 2006
Author: neal.norwitz
Date: Thu Apr 20 08:56:05 2006
New Revision: 45576
Modified:
python/trunk/Modules/posixmodule.c
Log:
Address issues brought up by MvL on python-checkins.
I tested this with valgrind on amd64.
The man pages I found for diff architectures are inconsistent on this.
I'm not entirely sure this change is correct for all architectures either.
Perhaps we should just over-allocate and not worry about it?
Modified: python/trunk/Modules/posixmodule.c
==============================================================================
--- python/trunk/Modules/posixmodule.c (original)
+++ python/trunk/Modules/posixmodule.c Thu Apr 20 08:56:05 2006
@@ -6809,7 +6809,7 @@
{
PyObject *result = NULL;
int name;
- char buffer[64];
+ char buffer[256];
if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) {
int len;
@@ -6827,12 +6827,12 @@
}
else {
if ((unsigned int)len >= sizeof(buffer)) {
- result = PyString_FromStringAndSize(NULL, len+1);
+ result = PyString_FromStringAndSize(NULL, len-1);
if (result != NULL)
- confstr(name, PyString_AS_STRING(result), len+1);
+ confstr(name, PyString_AS_STRING(result), len);
}
else
- result = PyString_FromString(buffer);
+ result = PyString_FromStringAndSize(buffer, len-1);
}
}
return result;
More information about the Python-checkins
mailing list