Update of /cvsroot/pypgsql/pypgsql
In directory usw-pr-cvs1:/tmp/cvs-serv23156
Modified Files:
pgboolean.c
Log Message:
06SEP2001 gh Fix bug in PgBoolean_FromString: leading whitespace in PgBoolean
constructor doesn't lead to segfaults any more; also improve and
simplify the string stripping in this method.
Index: pgboolean.c
===================================================================
RCS file: /cvsroot/pypgsql/pypgsql/pgboolean.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** pgboolean.c 2001/08/24 22:26:00 1.8
--- pgboolean.c 2001/09/06 03:58:12 1.9
***************
*** 33,36 ****
--- 33,38 ----
| Date Ini Description |
| --------- --- ------------------------------------------------------- |
+ | 06SEP2001 gh Fix bug in PgBoolean_FromString; also improve and |
+ | simplify the string stripping in this method. |
| 09AUG2001 bga Change code to use Py_BuildValue() for creating Python |
| objects from C values (where possible). |
***************
*** 78,85 ****
PyObject *PgBoolean_FromString(char *s)
{
! char *p, *e;
PyObject *b = (PyObject *)NULL;
! if ((p = PyMem_Strdup(s)) == (char *)NULL)
{
PyErr_SetString(PyExc_MemoryError,
--- 80,87 ----
PyObject *PgBoolean_FromString(char *s)
{
! char *pstart, *p, *e;
PyObject *b = (PyObject *)NULL;
! if ((pstart = PyMem_Strdup(s)) == (char *)NULL)
{
PyErr_SetString(PyExc_MemoryError,
***************
*** 87,95 ****
return (PyObject *)NULL;
}
while (*p && isspace(Py_CHARMASK((unsigned int)(*p))))
p++;
! for (e = (p + strlen(p) - 1); e > p; --e)
{
if (isspace((int)Py_CHARMASK((unsigned int)(*e))))
--- 89,98 ----
return (PyObject *)NULL;
}
+ p = pstart;
while (*p && isspace(Py_CHARMASK((unsigned int)(*p))))
p++;
! for (e = p; e < p + strlen(p); e++)
{
if (isspace((int)Py_CHARMASK((unsigned int)(*e))))
***************
*** 100,104 ****
*e = (unsigned char)toupper((int)Py_CHARMASK((unsigned int)(*e)));
}
- *e = (unsigned char)toupper((int)Py_CHARMASK((unsigned int)(*e)));
switch (*p)
--- 103,106 ----
***************
*** 142,146 ****
}
! PyMem_Free(p);
if (b != (PyObject *)NULL)
--- 144,148 ----
}
! PyMem_Free(pstart);
if (b != (PyObject *)NULL)
|