Skip to content

Commit 3c7ac7e

Browse files
authored
Add two missing error checks in hamt.c (GH-5851)
1 parent e405096 commit 3c7ac7e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Python/hamt.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,9 @@ hamt_node_collision_without(PyHamtNode_Collision *self,
15101510
PyHamtNode_Collision *new = (PyHamtNode_Collision *)
15111511
hamt_node_collision_new(
15121512
self->c_hash, Py_SIZE(self) - 2);
1513+
if (new == NULL) {
1514+
return W_ERROR;
1515+
}
15131516

15141517
/* Copy all other keys from `self` to `new` */
15151518
Py_ssize_t i;
@@ -1742,7 +1745,10 @@ hamt_node_array_assoc(PyHamtNode_Array *self,
17421745
Set the key to it./ */
17431746
child_node = hamt_node_assoc(
17441747
node, shift + 5, hash, key, val, added_leaf);
1745-
if (child_node == (PyHamtNode *)self) {
1748+
if (child_node == NULL) {
1749+
return NULL;
1750+
}
1751+
else if (child_node == (PyHamtNode *)self) {
17461752
Py_DECREF(child_node);
17471753
return (PyHamtNode *)self;
17481754
}

0 commit comments

Comments
 (0)