[Python-checkins] r46671 - in python/trunk: Lib/bsddb/dbobj.py Lib/bsddb/test/test_all.py Lib/test/test_bsddb3.py Misc/NEWS Modules/_bsddb.c
Tim Peters
tim.peters at gmail.com
Tue Jun 6 21:43:27 CEST 2006
> Author: gregory.p.smith
> Date: Mon Jun 5 19:38:04 2006
> New Revision: 46671
>
> Modified:
> python/trunk/Lib/bsddb/dbobj.py
> python/trunk/Lib/bsddb/test/test_all.py
> python/trunk/Lib/test/test_bsddb3.py
> python/trunk/Misc/NEWS
> python/trunk/Modules/_bsddb.c
> Log:
> * add support for DBSequence objects [patch #1466734]
Coverity generated what appear to be legitimate complaints about this part:
> +#if (DBVER >= 43)
> +static PyObject*
> +DBSequence_construct(PyObject* self, PyObject* args, PyObject* kwargs)
> +{
> + PyObject* dbobj = NULL;
> + int flags = 0;
> + static char* kwnames[] = { "db", "flags", NULL};
> +
> + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:DBSequence", kwnames, &dbobj, &flags))
> + return NULL;
> + if (dbobj == Py_None)
> + dbobj = NULL;
> + else if (dbobj && !DBObject_Check(dbobj)) {
> + makeTypeError("DB", dbobj);
> + return NULL;
> + }
> + return (PyObject* )newDBSequenceObject((DBObject*)dbobj, flags);
> +}
> +#endif
1. It shouldn't be possible for a successful PyArg_ParseTupleAndKeywords()
call to leave dbobj == NULL, so the "dbobj &&" part of the last test
appears to be pointless.
2. If dbobj == Py_None, then dbobj is forced to NULL, and
newDBSequenceObject() will then be called with a NULL first argument. This
is the one Coverity spotted: newDBSequenceObject() will segfault if it's
called with a NULL first argument.
I don't know what this function _should_ do if dbobj==Py_None, but
segfaulting probably isn't the intent ;-)
More information about the Python-checkins
mailing list