dbrec: improper use of DBENTRY
use of DBENTRY after free and leak of same
This commit is contained in:
@ -73,25 +73,24 @@ static PyObject* pyRecord_rtype(pyRecord *self)
|
|||||||
|
|
||||||
static PyObject* pyRecord_info(pyRecord *self, PyObject *args)
|
static PyObject* pyRecord_info(pyRecord *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long ret;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
PyObject *def = NULL;
|
PyObject *ret = NULL;
|
||||||
DBENTRY entry;
|
DBENTRY entry;
|
||||||
|
|
||||||
if(!PyArg_ParseTuple(args, "s|O", &name, &def))
|
if(!PyArg_ParseTuple(args, "s|O", &name, &ret))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Py_XINCREF(ret);
|
||||||
|
|
||||||
dbCopyEntryContents(&self->entry, &entry);
|
dbCopyEntryContents(&self->entry, &entry);
|
||||||
ret = dbFindInfo(&entry, name);
|
if(!dbFindInfo(&entry, name)) {
|
||||||
|
Py_XDECREF(ret);
|
||||||
|
ret = PyString_FromString(dbGetInfoString(&entry));
|
||||||
|
}
|
||||||
dbFinishEntry(&entry);
|
dbFinishEntry(&entry);
|
||||||
|
|
||||||
if(!ret)
|
if(!ret)
|
||||||
return PyString_FromString(dbGetInfoString(&entry));
|
|
||||||
|
|
||||||
Py_XINCREF(def);
|
|
||||||
if(!def)
|
|
||||||
PyErr_SetNone(PyExc_KeyError);
|
PyErr_SetNone(PyExc_KeyError);
|
||||||
return def;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* pyRecord_infos(pyRecord *self)
|
static PyObject* pyRecord_infos(pyRecord *self)
|
||||||
@ -117,6 +116,8 @@ static PyObject* pyRecord_infos(pyRecord *self)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dbFinishEntry(&entry);
|
||||||
|
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user