Author: cito
Date: Thu Jan 28 15:08:29 2016
New Revision: 794

Log:
Fix regarding reference counting in typecast call

Modified:
   trunk/pgmodule.c

Modified: trunk/pgmodule.c
==============================================================================
--- trunk/pgmodule.c    Thu Jan 28 15:07:41 2016        (r793)
+++ trunk/pgmodule.c    Thu Jan 28 15:08:29 2016        (r794)
@@ -796,8 +796,10 @@
                                        element = 
PyBytes_FromStringAndSize(estr, esize);
                                        if (element && cast)
                                        {
+                                               PyObject *tmp = element;
                                                element = 
PyObject_CallFunctionObjArgs(
                                                        cast, element, NULL);
+                                               Py_DECREF(tmp);
                                        }
                                }
                                if (escaped) PyMem_Free(estr);
@@ -981,8 +983,12 @@
                                                if (ecast)
                                                {
                                                        if (ecast != Py_None)
+                                                       {
+                                                               PyObject *tmp = 
element;
                                                                element = 
PyObject_CallFunctionObjArgs(
                                                                        ecast, 
element, NULL);
+                                                               Py_DECREF(tmp);
+                                                       }
                                                }
                                                else
                                                {
@@ -990,8 +996,12 @@
                                                }
                                        }
                                        else
+                                       {
+                                               PyObject *tmp = element;
                                                element = 
PyObject_CallFunctionObjArgs(
                                                        cast, element, NULL);
+                                               Py_DECREF(tmp);
+                                       }
                                }
                        }
                        if (escaped) PyMem_Free(estr);
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to