Author: cito
Date: Fri Nov 27 17:30:33 2015
New Revision: 652

Log:
Fix issue with some cleanup code in the C module

Modified:
   branches/4.x/module/pgmodule.c
   trunk/module/pgmodule.c

Modified: branches/4.x/module/pgmodule.c
==============================================================================
--- branches/4.x/module/pgmodule.c      Fri Nov 27 13:29:58 2015        (r651)
+++ branches/4.x/module/pgmodule.c      Fri Nov 27 17:30:33 2015        (r652)
@@ -2611,9 +2611,7 @@
                                        *s = PyUnicode_AsEncodedString(obj, 
enc, "strict");
                                if (*s == NULL)
                                {
-                                       free(lparms); free(parms); free(str);
-                                       PyErr_SetString(PyExc_UnicodeError, 
"query parameter"
-                                               " could not be decoded (bad 
client encoding)");
+                                       free(lparms); free(parms);
                                        while (i--)
                                        {
                                                if (*--s)
@@ -2621,6 +2619,9 @@
                                                        Py_DECREF(*s);
                                                }
                                        }
+                                       free(str);
+                                       PyErr_SetString(PyExc_UnicodeError, 
"query parameter"
+                                               " could not be decoded (bad 
client encoding)");
                                        return NULL;
                                }
                                *p = PyString_AsString(*s);
@@ -2631,9 +2632,7 @@
                                *s = PyObject_Str(obj);
                                if (*s == NULL)
                                {
-                                       free(lparms); free(parms); free(str);
-                                       PyErr_SetString(PyExc_TypeError,
-                                               "query parameter has no string 
representation");
+                                       free(lparms); free(parms);
                                        while (i--)
                                        {
                                                if (*--s)
@@ -2641,6 +2640,9 @@
                                                        Py_DECREF(*s);
                                                }
                                        }
+                                       free(str);
+                                       PyErr_SetString(PyExc_TypeError,
+                                               "query parameter has no string 
representation");
                                        return NULL;
                                }
                                *p = PyString_AsString(*s);

Modified: trunk/module/pgmodule.c
==============================================================================
--- trunk/module/pgmodule.c     Fri Nov 27 13:29:58 2015        (r651)
+++ trunk/module/pgmodule.c     Fri Nov 27 17:30:33 2015        (r652)
@@ -1216,7 +1216,7 @@
                                *s = get_encoded_string(obj, encoding);
                                if (!*s)
                                {
-                                       free(lparms); free(parms); free(str);
+                                       free(lparms); free(parms);
                                        while (i--)
                                        {
                                                if (*--s)
@@ -1224,7 +1224,9 @@
                                                        Py_DECREF(*s);
                                                }
                                        }
-                                       return NULL; /* pass the 
UnicodeEncodeError */
+                                       free(str);
+                                       /* pass the UnicodeEncodeError */
+                                       return NULL;
                                }
                                PyBytes_AsStringAndSize(*s, p, (Py_ssize_t *)l);
                        }
@@ -1233,7 +1235,7 @@
                                *s = PyObject_Str(obj);
                                if (!*s)
                                {
-                                       free(lparms); free(parms); free(str);
+                                       free(lparms); free(parms);
                                        while (i--)
                                        {
                                                if (*--s)
@@ -1241,6 +1243,7 @@
                                                        Py_DECREF(*s);
                                                }
                                        }
+                                       free(str);
                                        PyErr_SetString(PyExc_TypeError,
                                                "query parameter has no string 
representation");
                                        return NULL;
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to