summaryrefslogtreecommitdiff
path: root/dev-python/cbor2/files/cbor2-5.6.1-cext.patch
blob: 1695038e4b4294c5dbd0676453cd195b44d18172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From 4de6991ba29bf2290d7b9d83525eda7d021873df Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= <alex.gronholm@nextday.fi>
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 <http://semver.org/>`_.
 
+**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) {