From 4de6991ba29bf2290d7b9d83525eda7d021873df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sat, 3 Feb 2024 13:03:38 +0200 Subject: [PATCH] Check PyObject_Hash() return value for errors Fixes #213. --- docs/versionhistory.rst | 5 +++++ source/tags.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index 70948c5..c91cdd0 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -5,6 +5,11 @@ Version history This library adheres to `Semantic Versioning `_. +**UNRELEASED** + +- Fixed ``__hash__()`` of the C version of the ``CBORTag`` type crashing when there's a recursive + reference cycle + **5.6.1** (2024-02-01) - Fixed use-after-free in the decoder's C version when prematurely encountering the end of stream diff --git a/source/tags.c b/source/tags.c index b718f55..ceb0916 100644 --- a/source/tags.c +++ b/source/tags.c @@ -182,6 +182,8 @@ CBORTag_hash(CBORTagObject *self) goto exit; ret = PyObject_Hash(tmp); + if (ret == -1) + goto exit; // Remove id(self) from thread_locals.running_hashes if (PySet_Discard(running_hashes, self_id) == -1) {