summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2008-08-24 05:48:10 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2008-08-24 05:48:10 (GMT)
commit2f99b241721f72c9f55617479709b589496c093d (patch)
tree46df4e6e2d10edb45724eb675519b8ae0c563998 /Objects
parentc4b153542d63474431f2ba3b83d531cafb1748e9 (diff)
downloadcpython-2f99b241721f72c9f55617479709b589496c093d.zip
cpython-2f99b241721f72c9f55617479709b589496c093d.tar.gz
cpython-2f99b241721f72c9f55617479709b589496c093d.tar.bz2
Merged revisions 66006 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes) ........ r66006 | neal.norwitz | 2008-08-23 22:04:52 -0700 (Sat, 23 Aug 2008) | 25 lines 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. ........
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringlib/formatter.h5
-rw-r--r--Objects/structseq.c20
2 files changed, 18 insertions, 7 deletions
diff --git a/Objects/stringlib/formatter.h b/Objects/stringlib/formatter.h
index b964435..aa99123 100644
--- a/Objects/stringlib/formatter.h
+++ b/Objects/stringlib/formatter.h
@@ -641,7 +641,10 @@ format_int_or_long_internal(PyObject *value, const InternalFormatSpec *format,
/* We know this can't fail, since we've already
reserved enough space. */
STRINGLIB_CHAR *pstart = p + n_leading_chars;
- int r = STRINGLIB_GROUPING(pstart, n_digits, n_digits,
+#ifndef NDEBUG
+ int r =
+#endif
+ STRINGLIB_GROUPING(pstart, n_digits, n_digits,
spec.n_total+n_grouping_chars-n_leading_chars,
NULL, 0);
assert(r);
diff --git a/Objects/structseq.c b/Objects/structseq.c
index 091370c..808f938 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -32,6 +32,8 @@ PyStructSequence_New(PyTypeObject *type)
PyStructSequence *obj;
obj = PyObject_New(PyStructSequence, type);
+ if (obj == NULL)
+ return NULL;
Py_SIZE(obj) = VISIBLE_SIZE_TP(type);
return (PyObject*) obj;
@@ -522,10 +524,16 @@ PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)
Py_INCREF(type);
dict = type->tp_dict;
- PyDict_SetItemString(dict, visible_length_key,
- PyLong_FromLong((long) desc->n_in_sequence));
- PyDict_SetItemString(dict, real_length_key,
- PyLong_FromLong((long) n_members));
- PyDict_SetItemString(dict, unnamed_fields_key,
- PyLong_FromLong((long) n_unnamed_members));
+#define SET_DICT_FROM_INT(key, value) \
+ do { \
+ PyObject *v = PyLong_FromLong((long) value); \
+ if (v != NULL) { \
+ PyDict_SetItemString(dict, key, v); \
+ Py_DECREF(v); \
+ } \
+ } while (0)
+
+ SET_DICT_FROM_INT(visible_length_key, desc->n_in_sequence);
+ SET_DICT_FROM_INT(real_length_key, n_members);
+ SET_DICT_FROM_INT(unnamed_fields_key, n_unnamed_members);
}