Fix:
* crashes on memory allocation failure found with failmalloc
* memory leaks found with valgrind
* compiler warnings in opt mode which would lead to invalid memory reads
* problem using wrong name in decimal module reported by pychecker
Update the valgrind suppressions file with new leaks that are small/one-time
leaks we don't care about (ie, they are too hard to fix).
TBR=barry
TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes)
in opt mode:
valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
./python -E -tt ./Lib/test/regrtest.py -uall,-bsddb,-compiler \
-x test_logging test_ssl test_multiprocessing
valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
./python -E -tt ./Lib/test/regrtest.py test_multiprocessing
for i in `seq 1 4000` ; do
LD_PRELOAD=~/local/lib/libfailmalloc.so FAILMALLOC_INTERVAL=$i \
./python -c pass
done
At least some of these fixes should probably be backported to 2.5.
diff --git a/Python/getargs.c b/Python/getargs.c
index 7c9774f..766a2d7 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -1312,7 +1312,7 @@
}
static int
-getbuffer(PyObject *arg, Py_buffer *view, char**errmsg)
+getbuffer(PyObject *arg, Py_buffer *view, char **errmsg)
{
void *buf;
Py_ssize_t count;
@@ -1322,8 +1322,10 @@
return -1;
}
if (pb->bf_getbuffer) {
- if (pb->bf_getbuffer(arg, view, 0) < 0)
+ if (pb->bf_getbuffer(arg, view, 0) < 0) {
+ *errmsg = "convertible to a buffer";
return -1;
+ }
if (!PyBuffer_IsContiguous(view, 'C')) {
*errmsg = "contiguous buffer";
return -1;
@@ -1332,8 +1334,10 @@
}
count = convertbuffer(arg, &buf, errmsg);
- if (count < 0)
+ if (count < 0) {
+ *errmsg = "convertible to a buffer";
return count;
+ }
PyBuffer_FillInfo(view, NULL, buf, count, 1, 0);
return 0;
}
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index bd4f494..bdd9bd7 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -132,8 +132,8 @@
PyThreadState *tstate;
PyObject *bimod, *sysmod;
char *p;
- char *icodeset; /* On Windows, input codeset may theoretically
- differ from output codeset. */
+ char *icodeset = NULL; /* On Windows, input codeset may theoretically
+ differ from output codeset. */
char *codeset = NULL;
char *errors = NULL;
int free_codeset = 0;