[Python-checkins] Add two missing error checks in hamt.c (GH-5851)
Miss Islington (bot)
webhook-mailer at python.org
Thu Mar 8 01:21:37 EST 2018
https://github.com/python/cpython/commit/e724dd4e5e9bdb888169d7cd2ca415a2fc2c29ab
commit: e724dd4e5e9bdb888169d7cd2ca415a2fc2c29ab
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-03-07T22:21:34-08:00
summary:
Add two missing error checks in hamt.c (GH-5851)
(cherry picked from commit 3c7ac7ea2098c672e50402d1d1b5ee9f14586437)
Co-authored-by: Xiang Zhang <angwerzx at 126.com>
files:
M Python/hamt.c
diff --git a/Python/hamt.c b/Python/hamt.c
index e54d3a4c55f9..53a85723745e 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;
}
More information about the Python-checkins
mailing list