dbrec: improper use of DBENTRY

use of DBENTRY after free and leak of same
This commit is contained in:
Michael Davidsaver
2015-01-04 09:20:44 -05:00
parent 325fb87496
commit 7d527103bf

View File

@ -73,25 +73,24 @@ static PyObject* pyRecord_rtype(pyRecord *self)
static PyObject* pyRecord_info(pyRecord *self, PyObject *args)
{
long ret;
const char *name;
PyObject *def = NULL;
PyObject *ret = NULL;
DBENTRY entry;
if(!PyArg_ParseTuple(args, "s|O", &name, &def))
if(!PyArg_ParseTuple(args, "s|O", &name, &ret))
return NULL;
Py_XINCREF(ret);
dbCopyEntryContents(&self->entry, &entry);
ret = dbFindInfo(&entry, name);
if(!dbFindInfo(&entry, name)) {
Py_XDECREF(ret);
ret = PyString_FromString(dbGetInfoString(&entry));
}
dbFinishEntry(&entry);
if(!ret)
return PyString_FromString(dbGetInfoString(&entry));
Py_XINCREF(def);
if(!def)
PyErr_SetNone(PyExc_KeyError);
return def;
return ret;
}
static PyObject* pyRecord_infos(pyRecord *self)
@ -117,6 +116,8 @@ static PyObject* pyRecord_infos(pyRecord *self)
}
}
dbFinishEntry(&entry);
return dict;
}