Skip to content

Commit

Permalink
prevent undefined behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannguyen4 committed Sep 27, 2024
1 parent 0f159c5 commit 0f40295
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@
} \
PyObject *py_field = \
PyDict_GetItemWithError(py_policy, py_field_name); \
Py_DECREF(py_field_name); \
if (py_field == NULL && PyErr_Occurred()) { \
PyErr_Clear(); \
Py_DECREF(py_field_name); \
return as_error_update( \
err, AEROSPIKE_ERR_CLIENT, \
"Unable to fetch field from policy dictionary"); \
} \
else if (py_field) { \
Py_DECREF(py_field_name); \
\
if (py_field) { \
if (PyLong_Check(py_field)) { \
long field_val = PyLong_AsLong(py_field); \
if (field_val == -1 && PyErr_Occurred()) { \
Expand Down Expand Up @@ -99,14 +101,15 @@
} \
PyObject *py_exp_list = \
PyDict_GetItemWithError(py_policy, py_field_name); \
Py_DECREF(py_field_name); \
if (py_exp_list == NULL && PyErr_Occurred()) { \
PyErr_Clear(); \
Py_DECREF(py_field_name); \
return as_error_update( \
err, AEROSPIKE_ERR_CLIENT, \
"Unable to fetch field from policy dictionary"); \
} \
else if (py_exp_list) { \
Py_DECREF(py_field_name); \
if (py_exp_list) { \
if (convert_exp_list(self, py_exp_list, &exp_list, err) == \
AEROSPIKE_OK) { \
policy->filter_exp = exp_list; \
Expand Down

0 comments on commit 0f40295

Please sign in to comment.