diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-12-27 23:46:49 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2019-01-21 02:00:04 +0000 |
commit | 79de02d7d5d5612f6ac54a953cca3eaa8a641470 (patch) | |
tree | da4cfc79968a0729cfd7d954359e133ee33413cf /psycopg/replication_message_type.c | |
parent | 3e660229124ece642b505439e10e2590cec674c3 (diff) | |
download | psycopg2-79de02d7d5d5612f6ac54a953cca3eaa8a641470.tar.gz |
Stricter use of PyArg_ParseTuple typed objects
The function expect PyObject *, not subclasses.
Diffstat (limited to 'psycopg/replication_message_type.c')
-rw-r--r-- | psycopg/replication_message_type.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/psycopg/replication_message_type.c b/psycopg/replication_message_type.c index b37c402..6927cf6 100644 --- a/psycopg/replication_message_type.c +++ b/psycopg/replication_message_type.c @@ -58,12 +58,17 @@ replmsg_repr(replicationMessageObject *self) static int replmsg_init(PyObject *obj, PyObject *args, PyObject *kwargs) { - replicationMessageObject *self = (replicationMessageObject*) obj; + PyObject *cur = NULL; + replicationMessageObject *self = (replicationMessageObject *)obj; - if (!PyArg_ParseTuple(args, "O!O", &cursorType, &self->cursor, &self->payload)) + if (!PyArg_ParseTuple( + args, "O!O", &cursorType, &cur, &self->payload)) { return -1; - Py_XINCREF(self->cursor); - Py_XINCREF(self->payload); + } + + Py_INCREF(cur); + self->cursor = (cursorObject *)cur; + Py_INCREF(self->payload); self->data_size = 0; self->data_start = 0; @@ -76,7 +81,7 @@ replmsg_init(PyObject *obj, PyObject *args, PyObject *kwargs) static int replmsg_traverse(replicationMessageObject *self, visitproc visit, void *arg) { - Py_VISIT((PyObject* )self->cursor); + Py_VISIT((PyObject *)self->cursor); Py_VISIT(self->payload); return 0; } |