Skip to content

Commit

Permalink
Free memory in case of some errors in inserttable
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jan 30, 2022
1 parent febc879 commit 17792e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pgconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ conn_inserttable(connObject *self, PyObject *args)
else if (PyUnicode_Check(obj)) {
obj = get_encoded_string(obj, encoding);
if (!obj) {
Py_DECREF(iter_row);
PyMem_Free(buffer); Py_DECREF(iter_row);
return NULL; /* pass the UnicodeEncodeError */
}
PyBytes_AsStringAndSize(obj, &col, &slen);
Expand All @@ -789,7 +789,7 @@ conn_inserttable(connObject *self, PyObject *args)
PyErr_SetString(
PyExc_TypeError,
"The third argument must contain only strings");
Py_DECREF(iter_row);
PyMem_Free(buffer); Py_DECREF(iter_row);
return NULL;
}
col = PQescapeIdentifier(self->cnx, col, (size_t) slen);
Expand Down

0 comments on commit 17792e1

Please sign in to comment.