1[PATCH] deallocate the conversation response only in case of error 2 3Fixes https://bugzilla.redhat.com/show_bug.cgi?id=679714 4 5Downloaded from: 6http://pkgs.fedoraproject.org/cgit/PyPAM.git/plain/PyPAM-0.5.0-nofree.patch 7 8Signed-off-by: Peter Korsgaard <peter@korsgaard.com> 9diff --git a/PAMmodule.c b/PAMmodule.c 10index 03cb799..a7ff8a5 100644 11--- a/PAMmodule.c 12+++ b/PAMmodule.c 13@@ -24,8 +24,6 @@ typedef struct { 14 char *service; 15 char *user; 16 PyObject *callback; 17- struct pam_response *response_data; 18- int response_len; 19 PyObject *user_data; 20 void *dlh1, *dlh2; 21 } PyPAMObject; 22@@ -54,15 +52,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg, 23 24 Py_INCREF(self); 25 26- if (NULL != self->response_data) { 27- for (int i = 0; i < self->response_len; i++) { 28- free(self->response_data[0].resp); 29- } 30- free(self->response_data); 31- self->response_data = NULL; 32- self->response_len = 0; 33- } 34- 35 PyObject* msgList = PyList_New(num_msg); 36 37 for (int i = 0; i < num_msg; i++) { 38@@ -92,6 +81,10 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg, 39 char* resp_text; 40 int resp_retcode = 0; 41 if (!PyArg_ParseTuple(respTuple, "si", &resp_text, &resp_retcode)) { 42+ while (i > 0) { 43+ free((--spr)->resp); 44+ --i; 45+ } 46 free(*resp); 47 Py_DECREF(respList); 48 return PAM_CONV_ERR; 49@@ -100,10 +93,6 @@ static int PyPAM_conv(int num_msg, const struct pam_message **msg, 50 spr->resp_retcode = resp_retcode; 51 Py_DECREF(respTuple); 52 } 53- 54- // Save this so we can free it later. 55- self->response_data = *resp; 56- self->response_len = PyList_Size(respList); 57 58 Py_DECREF(respList); 59 60@@ -144,8 +133,6 @@ static PyObject * PyPAM_pam(PyObject *self, PyObject *args) 61 p->user = NULL; 62 Py_INCREF(Py_None); 63 p->callback = Py_None; 64- p->response_data = NULL; 65- p->response_len = 0; 66 Py_INCREF(Py_None); 67 p->user_data = Py_None; 68 69