Skip to content

Commit

Permalink
Use INCREF and DECREF instead of X counterparts; fix mem leak
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannguyen4 committed Jul 17, 2023
1 parent d1f883c commit 4527c16
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/client/batch_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,23 @@ PyObject *AerospikeClient_BatchRead(AerospikeClient *self, PyObject *args,
PyObject *py_key = PyList_GetItem(py_keys, i);
as_key *tmp_key = (as_key *)as_vector_get(&tmp_keys, i);

Py_XINCREF(py_key);
Py_INCREF(py_key);
if (!PyTuple_Check(py_key)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM,
"key should be an aerospike key tuple");
Py_XDECREF(py_key);
Py_DECREF(py_key);
goto CLEANUP2;
}

pyobject_to_key(&err, py_key, tmp_key);
if (err.code != AEROSPIKE_OK) {
as_error_update(&err, AEROSPIKE_ERR_PARAM,
"failed to convert key at index: %d", i);
Py_DECREF(py_key);
goto CLEANUP2;
}

Py_DECREF(py_key);
processed_key_count++;
}

Expand Down

0 comments on commit 4527c16

Please sign in to comment.