summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiang Zhang <angwerzx@126.com>2018-03-08 05:59:46 (GMT)
committerGitHub <noreply@github.com>2018-03-08 05:59:46 (GMT)
commit3c7ac7ea2098c672e50402d1d1b5ee9f14586437 (patch)
tree2009f628ad44bd7e392c6b42c8af367f39ace6cd
parente405096ea91f516d411095b6fea4eec9668eac88 (diff)
downloadcpython-3c7ac7ea2098c672e50402d1d1b5ee9f14586437.zip
cpython-3c7ac7ea2098c672e50402d1d1b5ee9f14586437.tar.gz
cpython-3c7ac7ea2098c672e50402d1d1b5ee9f14586437.tar.bz2
Add two missing error checks in hamt.c (GH-5851)
-rw-r--r--Python/hamt.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/hamt.c b/Python/hamt.c
index e54d3a4..53a8572 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -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;
}