mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-17 01:20:32 +03:00
Fixed memory leak in lobject
This commit is contained in:
parent
4eb295a8ca
commit
5480cf5332
|
@ -1,3 +1,9 @@
|
||||||
|
2008-12-04 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
|
* psycopg/lobject_type.c: fixed memory leak. The patch was kindly
|
||||||
|
sent from a psycopg user but I wrongly deleted the email so no
|
||||||
|
kudos (and I had to fix the problem by myself!)
|
||||||
|
|
||||||
2008-11-25 Federico Di Gregorio <fog@initd.org>
|
2008-11-25 Federico Di Gregorio <fog@initd.org>
|
||||||
|
|
||||||
* psycopg/cursor_type.c: integrated patch from Alejandro Dubrovsky.
|
* psycopg/cursor_type.c: integrated patch from Alejandro Dubrovsky.
|
||||||
|
|
|
@ -95,6 +95,7 @@ psyco_lobj_write(lobjectObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
psyco_lobj_read(lobjectObject *self, PyObject *args)
|
psyco_lobj_read(lobjectObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
PyObject *res;
|
||||||
int where, end, size = -1;
|
int where, end, size = -1;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
|
@ -111,13 +112,19 @@ psyco_lobj_read(lobjectObject *self, PyObject *args)
|
||||||
size = end - where;
|
size = end - where;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buffer = PyMem_Malloc(size)) == NULL) return NULL;
|
if ((buffer = PyMem_Malloc(size)) == NULL) {
|
||||||
|
PyErr_NoMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
if ((size = lobject_read(self, buffer, size)) < 0) {
|
if ((size = lobject_read(self, buffer, size)) < 0) {
|
||||||
PyMem_Free(buffer);
|
PyMem_Free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PyString_FromStringAndSize(buffer, size);
|
res = PyString_FromStringAndSize(buffer, size);
|
||||||
|
PyMem_Free(buffer);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* seek method - seek in the lobject */
|
/* seek method - seek in the lobject */
|
||||||
|
|
|
@ -137,6 +137,11 @@
|
||||||
<File name="tests/test_dates.py" subtype="Code" buildaction="Nothing" />
|
<File name="tests/test_dates.py" subtype="Code" buildaction="Nothing" />
|
||||||
<File name="tests/test_lobject.py" subtype="Code" buildaction="Nothing" />
|
<File name="tests/test_lobject.py" subtype="Code" buildaction="Nothing" />
|
||||||
<File name="tests/test_quote.py" subtype="Code" buildaction="Nothing" />
|
<File name="tests/test_quote.py" subtype="Code" buildaction="Nothing" />
|
||||||
|
<File name="psycopg/cursor_type.c.~1~" subtype="Code" buildaction="Nothing" />
|
||||||
|
<File name="psycopg/lobject.h" subtype="Code" buildaction="Nothing" />
|
||||||
|
<File name="psycopg/lobject_int.c" subtype="Code" buildaction="Compile" />
|
||||||
|
<File name="psycopg/lobject_type.c" subtype="Code" buildaction="Compile" />
|
||||||
|
<File name="psycopg/typecast_basic.c.old" subtype="Code" buildaction="Nothing" />
|
||||||
</Contents>
|
</Contents>
|
||||||
<compiler ctype="GccCompiler" />
|
<compiler ctype="GccCompiler" />
|
||||||
<MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" />
|
<MonoDevelop.ChangeLogAddIn.ChangeLogInfo policy="UpdateNearestChangeLog" />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user