Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4026,6 +4026,9 @@ def test_flag_comparisons(self):
self.assertNotEqual(d, c.flags)
self.assertNotEqual(c.flags, d)

self.assertNotEqual(None, c.flags)
self.assertNotEqual(c.flags, None)

@requires_IEEE_754
def test_float_operation(self):
Decimal = self.decimal.Decimal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix an out-of-bounds read in the C implementation of :mod:`decimal` when
comparing the ``flags`` or ``traps`` of a :class:`~decimal.Context` with an
object that is not a signal dict, such as ``None``.
3 changes: 2 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ signaldict_richcompare(PyObject *v, PyObject *w, int op)
decimal_state *state = get_module_state_by_def(Py_TYPE(v));
assert(PyDecSignalDict_Check(state, v));

if ((SdFlagAddr(v) == NULL) || (SdFlagAddr(w) == NULL)) {
if ((SdFlagAddr(v) == NULL) ||
(PyDecSignalDict_Check(state, w) && SdFlagAddr(w) == NULL)) {
return value_error_ptr(INVALID_SIGNALDICT_ERROR_MSG);
}

Expand Down
Loading