Add two missing error checks in hamt.c (GH-5851)

This commit is contained in:
Xiang Zhang 2018-03-08 13:59:46 +08:00 committed by GitHub
parent e405096ea9
commit 3c7ac7ea20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -1510,6 +1510,9 @@ hamt_node_collision_without(PyHamtNode_Collision *self,
PyHamtNode_Collision *new = (PyHamtNode_Collision *)
hamt_node_collision_new(
self->c_hash, Py_SIZE(self) - 2);
if (new == NULL) {
return W_ERROR;
}
/* Copy all other keys from `self` to `new` */
Py_ssize_t i;
@ -1742,7 +1745,10 @@ hamt_node_array_assoc(PyHamtNode_Array *self,
Set the key to it./ */
child_node = hamt_node_assoc(
node, shift + 5, hash, key, val, added_leaf);
if (child_node == (PyHamtNode *)self) {
if (child_node == NULL) {
return NULL;
}
else if (child_node == (PyHamtNode *)self) {
Py_DECREF(child_node);
return (PyHamtNode *)self;
}