Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 098f694

Browse files
committed
Coverity found bug: test result of PyTuple_New() against NULL before use.
Will backport.
1 parent a74a84d commit 098f694

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Modules/_bsddb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,12 +1084,12 @@ _db_associateCallback(DB* db, const DBT* priKey, const DBT* priData,
10841084
}
10851085
data = PyString_FromStringAndSize(priData->data, priData->size);
10861086
args = PyTuple_New(2);
1087-
PyTuple_SET_ITEM(args, 0, key); /* steals reference */
1088-
PyTuple_SET_ITEM(args, 1, data); /* steals reference */
1089-
1090-
result = PyEval_CallObject(callback, args);
1091-
1092-
if (result == NULL) {
1087+
if (args != NULL) {
1088+
PyTuple_SET_ITEM(args, 0, key); /* steals reference */
1089+
PyTuple_SET_ITEM(args, 1, data); /* steals reference */
1090+
result = PyEval_CallObject(callback, args);
1091+
}
1092+
if (args == NULL || result == NULL) {
10931093
PyErr_Print();
10941094
}
10951095
else if (result == Py_None) {

0 commit comments

Comments
 (0)