8000 respond to review · python/cpython@0be5d6c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0be5d6c

Browse files
committed
respond to review
1 parent 00a468c commit 0be5d6c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Modules/_blake2/blake2b_impl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,11 @@ py_blake2b_dealloc(PyObject *self)
391391
PyThread_free_lock(obj->lock);
392392
obj->lock = NULL;
393393
}
394-
PyTypeObject *tp = Py_TYPE(self);
395-
Py_DECREF(tp);
396394

397395
PyObject_Del(self);
396+
397+
PyTypeObject *tp = Py_TYPE(self);
398+
Py_DECREF(tp);
398399
}
399400

400401
static PyType_Slot blake2b_type_slots[] = {

Modules/_blake2/blake2module.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ static struct PyMethodDef blake2mod_functions[] = {
3737
#define ADD_INT(d, name, value) do { \
3838
PyObject *x = PyLong_FromLong(value); \
3939
if (!x) { \
40+
Py_DECREF(x); \
4041
return -1; \
4142
} \
4243
if (PyDict_SetItemString(d, name, x) < 0) { \
44+
Py_DECREF(x); \
4345
return -1; \
4446
} \
4547
Py_DECREF(x); \
@@ -53,6 +55,8 @@ static int blake2_exec(PyObject *m)
5355
st->blake2b_type = (PyTypeObject *)PyType_FromModuleAndSpec(
5456
m, &blake2b_type_spec, NULL);
5557

58+
if (NULL == st->blake2b_type)
59+
return -1;
5660
/* BLAKE2b */
5761
if (PyModule_AddType(m, st->blake2b_type) < 0) {
5862
return -1;
@@ -73,6 +77,9 @@ static int blake2_exec(PyObject *m)
7377
st->blake2s_type = (PyTypeObject *)PyType_FromModuleAndSpec(
7478
m, &blake2s_type_spec, NULL);
7579

80+
if (NULL == st->blake2s_type)
81+
return -1;
82+
7683
if (PyModule_AddType(m, st->blake2s_type) < 0) {
7784
return -1;
7885
}

Modules/_blake2/blake2s_impl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ py_blake2s_dealloc(PyObject *self)
391391
obj->lock = NULL;
392392
}
393393

394+
PyObject_Del(self);
395+
394396
PyTypeObject *tp = Py_TYPE(self);
395397
Py_DECREF(tp);
396-
397-
PyObject_Del(self);
398398
}
399399

400400
static PyType_Slot blake2s_type_slots[] = {

0 commit comments

Comments
 (0)
0