mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
Fix off-by-one error in PyMem_Malloc() call in
psyco_conn_set_client_encoding(). Fixes #211
This commit is contained in:
parent
6c2e3ab49b
commit
b5f4a5f6c2
|
@ -195,12 +195,12 @@ psyco_conn_set_client_encoding(connectionObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "s", &enc)) return NULL;
|
||||
|
||||
/* convert to upper case and remove '-' and '_' from string */
|
||||
buffer = PyMem_Malloc(strlen(enc));
|
||||
buffer = PyMem_Malloc(strlen(enc)+1);
|
||||
for (i=j=0 ; i < strlen(enc) ; i++) {
|
||||
if (enc[i] == '_' || enc[i] == '-')
|
||||
continue;
|
||||
else
|
||||
buffer[j++] = toupper(enc[i]);
|
||||
continue;
|
||||
else
|
||||
buffer[j++] = toupper(enc[i]);
|
||||
}
|
||||
buffer[j] = '\0';
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user