log_tenpower = f*M # exact
else:
log_d = 0 # error < 2.31
- log_tenpower = div_nearest(f, 10**-p) # error < 0.5
+ log_tenpower = _div_nearest(f, 10**-p) # error < 0.5
return _div_nearest(log_tenpower+log_d, 100)
Core and Builtins
-----------------
+- Fix crashes on memory allocation failure found with failmalloc.
+
+- Fix memory leaks found with valgrind and update suppressions file.
+
+- Fix compiler warnings in opt mode which would lead to invalid memory reads.
+
+- Fix problem using wrong name in decimal module reported by pychecker.
+
- Issue #3642: Changed type of numarenas from uint to size_t
in order to silence a compilier warning on 64bit OSes.
# Will need to fix that.
#
+{
+ Suppress leaking the GIL. Happens once per process, see comment in ceval.c.
+ Memcheck:Leak
+ fun:malloc
+ fun:PyThread_allocate_lock
+ fun:PyEval_InitThreads
+}
+
+{
+ Suppress leaking the GIL after a fork.
+ Memcheck:Leak
+ fun:malloc
+ fun:PyThread_allocate_lock
+ fun:PyEval_ReInitThreads
+}
+
+{
+ Suppress leaking the autoTLSkey. This looks like it shouldn't leak though.
+ Memcheck:Leak
+ fun:malloc
+ fun:PyThread_create_key
+ fun:_PyGILState_Init
+ fun:Py_InitializeEx
+ fun:Py_Main
+}
+
+{
+ Hmmm, is this a real leak or like the GIL?
+ Memcheck:Leak
+ fun:malloc
+ fun:PyThread_ReInitTLS
+}
+
{
Handle PyMalloc confusing valgrind (possibly leaked)
Memcheck:Leak
ffi_ofs = 0;
}
+ assert(stgdict->format == NULL);
if (isStruct && !isPacked) {
stgdict->format = alloc_format_string(NULL, "T{");
} else {
#undef realdict
if (isStruct && !isPacked) {
+ char *ptr = stgdict->format;
stgdict->format = alloc_format_string(stgdict->format, "}");
+ PyMem_Free(ptr);
if (stgdict->format == NULL)
return -1;
}
ret = -1;
done:
+ PyMem_Free(name);
return ret;
}
#if defined (HAVE_SETITIMER) || defined (HAVE_GETITIMER)
ItimerError = PyErr_NewException("signal.ItimerError",
PyExc_IOError, NULL);
- PyDict_SetItemString(d, "ItimerError", ItimerError);
+ if (ItimerError != NULL)
+ PyDict_SetItemString(d, "ItimerError", ItimerError);
#endif
if (!PyErr_Occurred())
/* 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);
PyStructSequence *obj;
obj = PyObject_New(PyStructSequence, type);
+ if (obj == NULL)
+ return NULL;
Py_SIZE(obj) = VISIBLE_SIZE_TP(type);
return (PyObject*) obj;
Py_INCREF(type);
dict = type->tp_dict;
- PyDict_SetItemString(dict, visible_length_key,
- PyInt_FromLong((long) desc->n_in_sequence));
- PyDict_SetItemString(dict, real_length_key,
- PyInt_FromLong((long) n_members));
- PyDict_SetItemString(dict, unnamed_fields_key,
- PyInt_FromLong((long) n_unnamed_members));
+#define SET_DICT_FROM_INT(key, value) \
+ do { \
+ PyObject *v = PyInt_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);
}
}
static int
-getbuffer(PyObject *arg, Py_buffer *view, char**errmsg)
+getbuffer(PyObject *arg, Py_buffer *view, char **errmsg)
{
void *buf;
Py_ssize_t count;
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;
}
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;
}
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;