diff options
author | Federico Di Gregorio <fog@initd.org> | 2008-03-17 08:13:16 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2008-03-17 08:13:16 +0000 |
commit | 8103f44a125fc1207a5db6211ce902b0c70f8541 (patch) | |
tree | e7aa37b04bd4e8ff90b831552072dda25a8877fa /psycopg/adapter_datetime.c | |
parent | cceaa7331b82294952aa18beba63616187f2fd93 (diff) | |
download | psycopg2-8103f44a125fc1207a5db6211ce902b0c70f8541.tar.gz |
Fixed test segfault due to double decref.
Diffstat (limited to 'psycopg/adapter_datetime.c')
-rw-r--r-- | psycopg/adapter_datetime.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/psycopg/adapter_datetime.c b/psycopg/adapter_datetime.c index 98922d3..1a68a67 100644 --- a/psycopg/adapter_datetime.c +++ b/psycopg/adapter_datetime.c @@ -406,17 +406,18 @@ psyco_TimestampFromTicks(PyObject *self, PyObject *args) t = (time_t)round(ticks); ticks -= (double)t; if (localtime_r(&t, &tm)) { - args = Py_BuildValue("iiiiidO", - tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, - tm.tm_hour, tm.tm_min, - (double)tm.tm_sec + ticks, - pyPsycopgTzLOCAL); - if (args) { -/* Dprintf("psyco_TimestampFromTicks: args->refcnt = %d", args->ob_refcnt);*/ - res = psyco_Timestamp(self, args); - Py_DECREF(args); + PyObject *value = Py_BuildValue("iiiiidO", + tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, + (double)tm.tm_sec + ticks, + pyPsycopgTzLOCAL); + if (value) { + /* we don't decref the value here because the call to + psyco_Timestamp will do that by calling PyArg_ParseTuple */ + res = psyco_Timestamp(self, value); } } + return res; } |