diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-12-25 15:00:05 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-12-31 03:18:27 +0100 |
| commit | f6fefbea64d699ca7eb041fb36ebc0ca4d2baa42 (patch) | |
| tree | 8b0d76055641a7b3c9dda8101398cd378c77accb /psycopg/connection_int.c | |
| parent | 3214c23f51c8effa7e78f9a7f59735c5b3e10868 (diff) | |
| download | psycopg2-f6fefbea64d699ca7eb041fb36ebc0ca4d2baa42.tar.gz | |
Function psycopg_ensure_bytes converted in a "filter" stealing a ref.
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index ee4bebc..6d281b3 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -239,7 +239,6 @@ conn_encoding_to_codec(const char *enc) char *tmp; Py_ssize_t size; PyObject *pyenc = NULL; - PyObject *pybenc = NULL; char *rv = NULL; /* Find the Py codec name from the PG encoding */ @@ -250,11 +249,12 @@ conn_encoding_to_codec(const char *enc) } /* Convert the codec in a bytes string to extract the c string. */ - if (!(pybenc = psycopg_ensure_bytes(pyenc))) { + Py_INCREF(pyenc); + if (!(pyenc = psycopg_ensure_bytes(pyenc))) { goto exit; } - if (-1 == Bytes_AsStringAndSize(pybenc, &tmp, &size)) { + if (-1 == Bytes_AsStringAndSize(pyenc, &tmp, &size)) { goto exit; } @@ -262,8 +262,7 @@ conn_encoding_to_codec(const char *enc) rv = psycopg_strdup(tmp, size); exit: - /* pyenc is borrowed: no decref. */ - Py_XDECREF(pybenc); + Py_XDECREF(pyenc); return rv; } |
